Maven WSDL2 JAVA JAVA类没有生成

时间:2016-06-07 02:44:52

标签: maven soap jax-ws spring-ws

请在下面找到代码段。

我使用pom.xml生成java类,但是我没有成功。请告诉我出错的地方:

<?xml version="1.0" encoding="UTF-8"?>
<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.github</groupId>
    <artifactId>spring-ws-client</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Spring WS sample client application</name>
    <description>The Spring WS sample client application</description>

 <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-core</artifactId>
            <version>2.1.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-security</artifactId>
            <version>2.1.4.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
            <version>3.1.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
        </dependency>
        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>3.1</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.3.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>jaxws-maven-plugin</artifactId>
                    <version>1.12</version>
                    <executions>
                        <execution>
                     <id> WSDL 1</id>
                     <phase>generate-sources</phase>
                            <goals>
                                <goal>wsimport</goal>
                            </goals>
                    <configuration>
                        <wsdlDirectory>src/main/resources</wsdlDirectory>
                        <wsdlFiles>
                            <wsdlFile>cen_1.0.wsdl</wsdlFile>
                        </wsdlFiles>
                        <keep>true</keep>
                        <packageName>com.xxx.oraclecrm.inbound.census.jaxb</packageName>
                        <sourceDestDir>src/main/java</sourceDestDir>
                    </configuration>
                        </execution>
                    </executions>

                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

控制台输出:

这里我没有得到构建失败,但插件没有生成任何代码。让我知道我哪里出错了。

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Spring WS sample client application 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ spring-ws-client ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ spring-ws-client ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ spring-ws-client ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\EOI\Downloads\spring-ws-client\spring-ws-client\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ spring-ws-client ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ spring-ws-client ---
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ spring-ws-client ---
[INFO] Building jar: C:\Users\EOI\Downloads\spring-ws-client\spring-ws-client\target\spring-ws-client-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.940 s
[INFO] Finished at: 2016-06-06T19:37:29-07:00
[INFO] Final Memory: 12M/212M
[INFO] ------------------------------------------------------------------------

1 个答案:

答案 0 :(得分:0)

我建议使用apache cxf codegen插件代替:

        <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>${cxf.version}</version>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <sourceRoot>target/generated-code/src</sourceRoot>
                        <defaultOptions>
                            <autoNameResolution>true</autoNameResolution>
                        </defaultOptions>
                        <wsdlOptions>
                            <wsdlOption>
                                <packagenames>
                                    <packagename>com.xxx.oraclecrm.inbound.census.jaxb</packagename>
                                </packagenames>
                                <wsdl>src/main/resources/cen_1.0.wsdl</wsdl>
                                <wsdlLocation>classpath:cen_1.0.wsdl</wsdlLocation>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>