我通过使用 maven-hyperjaxb3-plugin 实现了同样的事情检查如何完成:
<plugin>
<groupId>org.jvnet.hyperjaxb3</groupId>
<artifactId>maven-hyperjaxb3-plugin</artifactId>
<version>0.5.4</version>
<executions>
<execution>
<id>id1</id>
<inherited>false</inherited>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<args>
<param>-npa</param>
</args>
<generateDirectory>target/generated-sources/xjc2</generateDirectory>
<generatePackage>com.target.package</generatePackage>
<extension>true</extension>
<schemaIncludes>
<include>mine.xsd</include>
</schemaIncludes>
<forceRegenerate>false</forceRegenerate>
<removeOldOutput>true</removeOldOutput>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.1.12</version>
</dependency>
</dependencies>
</plugin>
以下是项目依赖项:
<dependencies>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.1.12</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.jvnet.hyperjaxb3</groupId>
<artifactId>hyperjaxb3-ejb-runtime</artifactId>
<version>0.3</version>
</dependency>
<!-- Roundtrip -->
<dependency>
<groupId>org.jvnet.hyperjaxb3</groupId>
<artifactId>hyperjaxb3-ejb-roundtrip
</artifactId>
<version>0.3</version>
</dependency>
</dependencies>
我定义了任何简单和复杂的类型,它就像一个魅力。希望能帮助到你!