如何使用jaxb2-maven-plugin将java类生成到源文件夹中?
2022-09-02 14:08:47
我使用jaxb2-maven-plugin来生成java类。有插件属性:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- The package of your generated sources -->
<packageName>com.bcap.me.JaxB</packageName>
<sources>
<source>src/main/resources/xsds/pos.xsd</source>
</sources>
</configuration>
</plugin>
运行插件后,在目录中创建类。但是我需要在源文件夹(包)中有类:如何做到这一点?mvn clean compile
target\classes\com\bcap\me\JaxB
src\main\java\com\bcap\me\JaxB
更新我添加了属性,但我不确定这种方法的正确性:outputDirectory
<!--<packageName>com.bcap.me.JaxB</packageName>-->
<outputDirectory>src/main/java/com/bcap/me/JaxB</outputDirectory>
更新
我解决了我的案件,就像:
<execution>
<id>xjc_pos</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<!-- The package of your generated sources -->
<packageName>com.bcap.me.JaxB</packageName>
<outputDirectory>src/main/java</outputDirectory>
<sources>
<source>src/main/resources/xsds/pos.xsd</source>
</sources>
<generateEpisode>false</generateEpisode>
<clearOutputDir>false</clearOutputDir>
</configuration>
</execution>
感谢@ulab