jaxws-maven-plugin 多次执行不工作

jaxws-maven-plugin multiple executions not working

我想为多个 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>

非常感谢任何解决方案的想法!

(P.S.Java8, Maven 3.6.2)

解决方案是 运行 "install" 生命周期而不是直接 jaxws:import 插件。