我使用jaxb2-maven-plugin
的schemagen
目标将Java类转换为xsd。com.example.entities
&com.example.model
应转换为&其余的包被忽略。如何在pom.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<executions>
<execution>
<id>schemagen</id>
<goals><goal>schemagen</goal></goals>
</execution>
</executions>
</plugin>
在涉水过了非常奇怪的FileNotFoundException
和ClassNotFoundException
之后,我发现通过这个StackOverflow的答案,jaxb2-maven-plugin
有Java 11的问题。
现在,我使用jax-maven-plugin相反,它具有包含特定文件夹/包的简单配置。
为了包含类org.examples.models
&仅限org.examples.entities
,可转换为xml:
<plugin>
<groupId>com.github.davidmoten</groupId>
<artifactId>jax-maven-plugin</artifactId>
<version>0.2</version>
<executions>
<execution>
<id>schemagen-source-option</id>
<phase>generate-sources</phase>
<goals><goal>schemagen</goal></goals>
<configuration>
<classpathScope>compile</classpathScope>
<sources>
<source>${basedir}/src/main/java/org/examples/models</source>
<source>${basedir}/src/main/java/org/examples/entities</source>
</sources>
<arguments>
<argument>-d</argument>
<argument>${jaxb.generated}</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>