无法使用codehaus.mojo jaxb2-maven-plugin创建java类

时间:2017-08-18 22:54:51

标签: java maven soap wsdl jaxb2-maven-plugin

我有一个基于Spring的Web应用程序,我正在尝试使用SOAP服务。我正在使用jaxb2-maven-plugin(org.codehaus.mojo)。但是我看到一个空的jaxb2文件夹,它在目标下被包装,我没有看到任何java类。我将wsdl正确放置在资源文件夹下。

以下是在pom.xml中创建的插件配置

True

以下是我运行 <build> <finalName>${project.artifactId}</finalName> <resources> <resource> <directory>src/main/resources</directory> </resource> <resource> <directory>src/main/java/com/xyz/rap/service/impl/wsdl</directory> <targetPath>wsdl</targetPath> </resource> <resource> <directory>src/main/config</directory> <targetPath>config</targetPath> </resource> </resources> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxb2-maven-plugin</artifactId> <version>1.6</version> <executions> <execution> <id>xjc</id> <goals> <goal>xjc</goal> </goals> </execution> </executions> <configuration> <!-- Package to store the generated file --> <packageName>com.xxx.gen.retail.abc</packageName> <!-- Treat the input as WSDL --> <wsdl>true</wsdl> <!-- Input is not XML schema --> <xmlschema>false</xmlschema> <!-- The location of the WSDL file --> <schemaDirectory>${project.basedir}/src/main/resources</schemaDirectory> <!-- The WSDL file that you saved earlier --> <schemaFiles>gene.wsdl</schemaFiles> <!-- Don't clear output directory on each run --> <clearOutputDir>false</clearOutputDir> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <!-- or whatever version you use --> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build> </project>

时的日志
"maven install"

它说在日志中解析和编译模式但我没有看到在日志中创建任何java类,我看到一个空的jaxb2文件夹和另一个空的generated-sources文件夹被创建。请参考下图:

enter image description here

2 个答案:

答案 0 :(得分:0)

jaxb2-maven-plugin默认情况下会将类创建为target/generated-sources/jaxb。如果您还没有将类添加到目标文件夹中,那么如果您使用的是Eclipse,则可以将此文件夹添加到项目构建路径中:右键单击项目并选择“构建路径&gt;使用源文件夹。

然后你需要运行mvn clean install它将清理或删除目标文件夹并重新生成所有内容。

答案 1 :(得分:0)

尝试使用codehaus 2.2版。请记住,您需要稍微更改一下xml,因为1.x和2.x之间存在差异。

说完之后我想告诉你我有类似的问题。但它可能是由别的东西造成的。我使用IntelliJ并在/ target / generated-sources /下生成空的jaxb文件夹。

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>2.2</version>
                <executions>
                    <execution>
                        <id>xjc</id>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <sources>
                        <source>/src/main/resources/xsd/</source>
                    </sources>
                    <outputDirectory>${project.basedir}/target/generated-sources/jaxb</outputDirectory>
                    <clearOutputDir>false</clearOutputDir>
                </configuration>
</plugin>
相关问题