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

问题描述 投票:0回答:1

我想为多个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。Java 8,Maven 3.6.2)

java maven jax-ws jaxws-maven-plugin
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.