maven jax-ws插件不会从wsdl生成客户端类

时间:2013-07-05 11:16:51

标签: web-services wsdl maven-2 jax-ws pom.xml

我使用 maven 2 创建了一个Web项目(它将部署在tomcat 7.0.35上),它应该作为 JAX-WS Web服务的客户端。我正在尝试从 wsdl 文件生成客户端类(我有1个wsdl和1个xsd)。 运行" mvn clean install "命令,没有生成类,我在控制台中看不到任何错误

这是我的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.test.ws</groupId>
  <artifactId>my_ws</artifactId>
  <packaging>war</packaging>
  <version>1.0</version>
  <name>cs Maven Webapp</name>
  <url>http://maven.apache.org</url>

  <build>
    <finalName>my_ws</finalName>
    <pluginManagement>
        <plugins>
         <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.8</version>
                <configuration>
                    <projectNameTemplate>
                        [artifactId]-[version]
                    </projectNameTemplate>
                    <wtpmanifest>true</wtpmanifest>
                    <wtpapplicationxml>true</wtpapplicationxml>
                    <wtpversion>2.0</wtpversion>
                    <manifest>
                        ${basedir}/src/main/resources/META-INF/MANIFEST.MF
                    </manifest>
                </configuration>
            </plugin>   
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                        <configuration>
                            <wsdlDirectory>${basedir}/src/main/resources/wsdl</wsdlDirectory>
                            <wsdlFiles>
                                <wsdlFile>my_ws.wsdl</wsdlFile>
                            </wsdlFiles>
                            <packageName>com.test.ws.client</packageName>
                            <sourceDestDir>${basedir}/target/generated-sources/</sourceDestDir>
                            <keep>true</keep>
                            <bindingFiles>
                                <bindingFile>${basedir}/src/main/resources/wsdl/binding.xml</bindingFile>
                                <bindingFile>${basedir}/src/main/resources/wsdl/jaxb-binding.xml</bindingFile>
                            </bindingFiles>
                        </configuration>
                        <phase>generate-sources</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>
  </build>


  <dependencies>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.9</version>
    </dependency>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc</artifactId>
        <version>11.2.0.2.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-rt</artifactId>
        <version>2.2.8</version>
    </dependency>
  </dependencies>

</project>

以下是binding.xml

<bindings
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    wsdlLocation="./my_ws.wsdl"
    xmlns="http://java.sun.com/xml/ns/jaxws">
        <!-- Disable default wrapper style -->
        <enableWrapperStyle>false</enableWrapperStyle>

</bindings>

jaxb-binding.xml

<jaxb:bindings version="2.1" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <jaxb:globalBindings generateElementProperty="false" />
</jaxb:bindings> 

1 个答案:

答案 0 :(得分:2)

使用&lt; pluginManagement&gt;时在pom文件中的元素,您不要声明插件使用,而是插件可用性。 &LT; pluginManagement&GT;在父pom中用于宣布可用于子节点的插件。

只需删除此元素,即可调用插件。