简体   繁体   English

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

[英]Unable to create java classes using codehaus.mojo jaxb2-maven-plugin

I have a spring based web application in which I am trying to consume a SOAP service. 我有一个基于Spring的Web应用程序,正在其中尝试使用SOAP服务。 I am using jaxb2-maven-plugin(org.codehaus.mojo) for that. 我为此使用jaxb2-maven-plugin(org.codehaus.mojo)。 However I see an empty jaxb2 folder which is crated under target and I dont see any java classes in it. 但是我看到一个空的jaxb2文件夹,该文件夹位于target下,并且看不到其中的任何Java类。 I have the wsdl placed correctly under the resources folder itself. 我将wsdl正确放置在资源文件夹下。

Below is the plugin config created in pom.xml 以下是在pom.xml中创建的插件配置

    <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>

Below is the log when I run "maven install" 下面是我运行"maven install"时的日志

  [INFO] Building rap-web Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
**[INFO] --- jaxb2-maven-plugin:1.6:xjc (xjc) @ rap-web ---
[INFO] Generating source...
[WARNING] No encoding specified; default platform encoding will be used for generated sources.
[INFO] parsing a schema...
[INFO] compiling a schema...
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ rap-web ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 15 resources
[INFO] Copying 3 resources to wsdl
[INFO] Copying 1 resource to config
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ rap-web ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 50 source files to C:\Users\xx67047\DSA-GIT-Projects\10.22.17-dsa-rap-services\rap-web\target\classes**
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ rap-web ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\xx67047\DSA-GIT-Projects\10.22.17-dsa-rap-services\rap-web\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ rap-web ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ rap-web ---

It says Parsing and compiling the schema in logs but I dont see any java classes getting created in the logs and I see an empty jaxb2 folder and an other empty generated-sources folder getting created. 它说在日志中解析和编译模式,但是我没有看到在日志中创建任何Java类,并且看到一个空的jaxb2文件夹和另一个空的生成源文件夹。 Please refer below image for that: 请参考下图:

在此处输入图片说明

jaxb2-maven-plugin will create classes by default into target/generated-sources/jaxb . jaxb2-maven-plugin默认会创建类到target/generated-sources/jaxb if you are stil not getting classes into target folder then If you are using Eclipse, you can add this folder into your project build path: right-clicking on project and selecting "Build Path > Use Source Folder. 如果您不希望将类添加到目标文件夹中,那么如果您使用的是Eclipse,则可以将此文件夹添加到项目构建路径中:右键单击项目,然后选择“构建路径>使用源文件夹”。

then you need to run mvn clean install it will clean or delete the target folder and regenerate everything. 那么您需要运行mvn clean install ,它将清理或删除目标文件夹并重新生成所有内容。

Try the version 2.2 of the codehaus. 尝试使用Codehaus 2.2版本。 Keep in mind that you will need to change your xml a bit since there is a difference between 1.x and 2.x. 请记住,由于1.x和2.x之间存在差异,因此您需要稍微更改xml。

Having said that I would like to tell you that I'm having a similar issue. 话虽如此,我想告诉你,我也有类似的问题。 But it could be caused by something else. 但这可能是由其他原因引起的。 I'm using IntelliJ and it's generating empty jaxb folder under the /target/generated-sources/. 我正在使用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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.codehaus.mojo:jaxb2-maven-plugin 2.0在哪里? - Where is org.codehaus.mojo:jaxb2-maven-plugin 2.0? codehaus.mojo gwt-maven-plugin:项目无法编译 - codehaus.mojo gwt-maven-plugin: project fails to compile 我想在每个使用org.codehaus.mojo jaxb2-maven-plugin插件生成的JAXB生成的文件中添加一行注释 - I want to add a single line comment in each JAXB generated file that have been generated using the org.codehaus.mojo jaxb2-maven-plugin plugin jaxws-maven-plugin或jaxb2-maven-plugin从WSDL创建Java类 - jaxws-maven-plugin or jaxb2-maven-plugin to create java classes from WSDL 无法执行目标 org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc (default-cli) - Getting Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc (default-cli) 骆驼在行动codehaus.mojo插件错误 - Camel in action codehaus.mojo plugin error 如何使用jaxb2-maven-plugin在源文件夹中生成java类? - How to generate java classes into source folder using jaxb2-maven-plugin? jaxb2-maven-plugin 雅加达和 java 11 - jaxb2-maven-plugin Jakarta and java 11 Java POM 插件问题(无法解析 mojo org.codehaus.mojo:exec-maven-plugin 的配置) - Java POM plugin issue (Unable to parse configuration of mojo org.codehaus.mojo:exec-maven-plugin) jaxb2-maven-plugin在java 9上失败了 - jaxb2-maven-plugin failing on java 9
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM