gpt4 book ai didi

java - jaxws-maven-plugin 多次执行不起作用

转载 作者:行者123 更新时间:2023-12-01 19:19:27 81 4
gpt4 key购买 nike

我想为多个 WSDL 生成 java 类。由于不同模式中的名称冲突,每个 WSDL 都应该位于一个 java 包中。我在 pom.xml 中创建了以下执行:

  <plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>service1</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlUrls>
<wsdlUrl>http://myserver/service1?wsdl</wsdlUrl>
</wsdlUrls>
<keep>false</keep>
<sourceDestDir>target/generatedclasses</sourceDestDir>
<packageName>com.myservice1</packageName>
</configuration>
</execution>
<execution>
<id>service2</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlUrls>
<wsdlUrl>http://myserver/service2?wsdl</wsdlUrl>
</wsdlUrls>
<keep>false</keep>
<sourceDestDir>target/generatedclasses</sourceDestDir>
<packageName>com.myservice2</packageName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

但是显然找不到 WSDL 位置:

[DEBUG] Configuring mojo org.codehaus.mojo:jaxws-maven-plugin:2.5:wsimport from plugin realm ClassRealm[plugin>org.codehaus.mojo:jaxws-maven-plugin:2.5, parent: sun.misc.Launcher$AppClassLoader@18b4aac2]
[DEBUG] Configuring mojo 'org.codehaus.mojo:jaxws-maven-plugin:2.5:wsimport' with basic configurator -->
[DEBUG] (f) bindingDirectory = C:\sandbox\ws-client\src\jaxws
[DEBUG] (f) destDir = C:\sandbox\ws-client\target\classes
[DEBUG] (f) extension = false
[DEBUG] (f) genJWS = false
[DEBUG] (f) implDestDir = C:\sandbox\ws-client\src\main\java
[DEBUG] (f) keep = true
[DEBUG] (f) pluginDescriptor = Component Descriptor: role: 'org.apache.maven.plugin.Mojo', implementation: 'org.codehaus.mojo.jaxws.HelpMojo', role hint: 'org.codehaus.mojo:jaxws-maven-plugin:2.5:help'
role: 'org.apache.maven.plugin.Mojo', implementation: 'org.codehaus.mojo.jaxws.MainWsGenMojo', role hint: 'org.codehaus.mojo:jaxws-maven-plugin:2.5:wsgen'
role: 'org.apache.maven.plugin.Mojo', implementation: 'org.codehaus.mojo.jaxws.TestWsGenMojo', role hint: 'org.codehaus.mojo:jaxws-maven-plugin:2.5:wsgen-test'
role: 'org.apache.maven.plugin.Mojo', implementation: 'org.codehaus.mojo.jaxws.MainWsImportMojo', role hint: 'org.codehaus.mojo:jaxws-maven-plugin:2.5:wsimport'
role: 'org.apache.maven.plugin.Mojo', implementation: 'org.codehaus.mojo.jaxws.TestWsImportMojo', role hint: 'org.codehaus.mojo:jaxws-maven-plugin:2.5:wsimport-test'
---
[DEBUG] (f) project = MavenProject: org.example:wsclient:1.0-SNAPSHOT @ C:\sandbox\ws-client\pom.xml
[DEBUG] (f) quiet = false
[DEBUG] (f) session = org.apache.maven.execution.MavenSession@22680f52
[DEBUG] (f) settings = org.apache.maven.execution.SettingsAdapter@39c11e6c
[DEBUG] (f) sourceDestDir = C:\sandbox\ws-client\target\generated-sources\wsimport
[DEBUG] (f) staleFile = C:\sandbox\ws-client\target\jaxws\stale
[DEBUG] (f) useJdkToolchainExecutable = false
[DEBUG] (f) verbose = false
[DEBUG] (f) wsdlDirectory = C:\sandbox\ws-client\src\wsdl
[DEBUG] (f) xadditionalHeaders = false
[DEBUG] (f) xdebug = false
[DEBUG] (f) xdisableAuthenticator = false
[DEBUG] (f) xdisableSSLHostnameVerification = false
[DEBUG] (f) xnoAddressingDataBinding = false
[DEBUG] (f) xnocompile = true
[DEBUG] (f) xuseBaseResourceAndURLToLoadWSDL = false
[DEBUG] -- end configuration --
[DEBUG] The wsdl Directory is C:\sandbox\ws-client\src\wsdl
[INFO] No WSDLs are found to process, Specify at least one of the following parameters: wsdlFiles, wsdlDirectory or wsdlUrls.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.808 s

我不明白为什么这个例子不起作用。看来配置是有效的(参见Multiple WSDLs Configurations With Maven JAXWS)

如果我将 configuration 元素向上移动两级,它就可以工作了! (但是我只能配置一次执行...)

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<wsdlUrls>
<wsdlUrl>http://myserver/service1?wsdl</wsdlUrl>
</wsdlUrls>
<keep>false</keep>
<sourceDestDir>target/generatedclasses</sourceDestDir>
<packageName>com.myservice1</packageName>
</configuration>
</plugin>
</plugins>
</build>

强烈感谢任何解决方案的想法!

(附:Java 8、Maven 3.6.2)

最佳答案

解决方案是运行“安装”生命周期而不是直接运行插件 jaxws:import。

关于java - jaxws-maven-plugin 多次执行不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59378448/

81 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com