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

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

我已经使用 ma​​ven 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> 

最佳答案

在 pom 文件中使用 元素时,您不声明插件的使用情况,而是声明插件的可用性。 在父 pom 中使用来宣布子 pom 使用的可用插件。

只要删除这个元素,插件就会被调用。

关于web-services - maven jax-ws 插件不会从 wsdl 生成客户端类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17487628/

相关文章:

java - 如何从基于 java 的服务获取声音

java - BPEL 模块中的外部 WSDL : Address already in use 8080

java - 使用 axistools-maven-plugin 时禁用附件支持

java - 使用 Maven 2 API 获取 WAR Artifact 的依赖项

java - org.apache.axis.wsdl.toJava.DuplicateFileException : Duplicate file name:

java - Dropwizard for Hibernate 中的 SQLite 方言

java - 在 Maven 测试中获取 native JNI 文件 (lwjgl)

java - 扩展 BaseTest 的 testNG 测试

javascript - $HTTP.Get 已取消

java - 将 wsdl 转换为 JAR 文件时出现错误