axistools-maven-plugin不从WSDL

时间:2016-06-30 16:36:56

标签: web-services maven-3 axis2 java-ee-6

我正在使用Apache Axis从我的WSDL文件生成java源代码。 maven运行成功,没有任何错误,但没有生成类。

问题:我在这里缺少什么?

<plugins>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>axistools-maven-plugin</artifactId>
        <version>1.4</version>
        <executions>
            <execution>
                <phase>generate-sources</phase>
                <goals>
                    <goal>wsdl2java</goal>
                </goals>
                <configuration>
                    <sourceDirectory>/src/main/resources</sourceDirectory>
                    <outputDirectory>/src/main/java</outputDirectory>
                    <wsdlFiles>
                        <wsdlFile>thesourcewsdlfile.wsdl</wsdlFile>
                    </wsdlFiles>
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>

我显然不确定此配置有什么问题。

1 个答案:

答案 0 :(得分:0)

尝试在maven项目中定义源和输出目录库,即使用标准maven属性在运行时指向正确的绝对路径,更改配置如下:

 <sourceDirectory>${basedir}/src/main/resources</sourceDirectory>
 <outputDirectory>${basedir}/src/main/java</outputDirectory>

根据此配置,thesourcewsdlfile.wsdl应位于src/main/resources/thesourcewsdlfile.wsdl

完整的插件配置应该是:

<plugins>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>axistools-maven-plugin</artifactId>
        <version>1.4</version>
        <executions>
            <execution>
                <phase>generate-sources</phase>
                <goals>
                    <goal>wsdl2java</goal>
                </goals>
                <configuration>
                    <sourceDirectory>${basedir}/src/main/resources</sourceDirectory>
                    <outputDirectory>${basedir}/src/main/java</outputDirectory>
                    <wsdlFiles>
                        <wsdlFile>thesourcewsdlfile.wsdl</wsdlFile>
                    </wsdlFiles>
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>

此外,必须将以下依赖项添加到项目中:

<dependencies>
    <dependency>
        <groupId>org.apache.axis</groupId>
        <artifactId>axis</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
        <groupId>javax.xml</groupId>
        <artifactId>jaxrpc-api</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4.1</version>
    </dependency>
    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>activation</artifactId>
        <version>1.1</version>
    </dependency>
</dependencies>

总的来说,将生成的源放在target目录下会好得多,因为它们是自动生成的,不应该添加到正在使用的版本控件中。然后,标准位置将是${project.build.directory}/generated-sources下的任何所需(有意义的)目录(其中${project.build.directory}是指向target目录的标准属性。)