我使用此插件来解决xsd的公开导入
<plugin> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> <version>0.8.1</version> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>generate</goal> </goals> </execution> </executions> <configuration> <args> <arg>-Xannotate</arg> <arg>-Xnamespace-prefix</arg> <arg>-nv</arg> </args> <extension>true</extension> <forceRegenerate>true</forceRegenerate> <bindingDirectory>${basedir}/src/main/resources/xjb</bindingDirectory> <bindingIncludes> <include>*.xjb</include> </bindingIncludes> <schemas> <schema> <fileset> <directory>${basedir}/src/main/resources/xsd</directory> <includes> <include>*.xsd</include> </includes> </fileset> </schema> <schema> <dependencyResource> <groupId>groupID</groupId> <artifactId>artifactID</artifactId> <resource>target.xsd</resource> </dependencyResource> </schema> </schemas> <episodes> <episode> <groupId>groupID</groupId> <artifactId>artifactID</artifactId> </episode> </episodes> <debug>true</debug> <verbose>true</verbose> <plugins> <plugin> <groupId>org.jvnet.jaxb2_commons</groupId> <artifactId>jaxb2-basics</artifactId> <version>0.6.2</version> </plugin> <plugin> <groupId>org.jvnet.jaxb2_commons</groupId> <artifactId>jaxb2-basics-annotate</artifactId> <version>0.6.2</version> </plugin> <plugin> <groupId>org.jvnet.jaxb2_commons</groupId> <artifactId>jaxb2-namespace-prefix</artifactId> <version>1.1</version> </plugin> </plugins> </configuration></plugin>
项目A的pom.xml插件
<plugin> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> <version>0.8.1</version> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>generate</goal> </goals> </execution> </executions> <configuration> <args> <arg>-Xannotate</arg> <arg>-nv</arg> <arg>-Xnamespace-prefix</arg> </args> <extension>true</extension> <schemas> <schema> <fileset> <directory>${basedir}/src/main/resources/xsd/</directory> <includes> <include>A.xsd</include> </includes> </fileset> </schema> </schemas> <bindingDirectory>src/main/resources/xjb</bindingDirectory> <bindingIncludes> <include>*.xjb</include> </bindingIncludes> <debug>true</debug> <verbose>true</verbose> <forceRegenerate>true</forceRegenerate> <plugins> <plugin> <groupId>org.jvnet.jaxb2_commons</groupId> <artifactId>jaxb2-basics</artifactId> <version>0.6.0</version> </plugin> <plugin> <groupId>org.jvnet.jaxb2_commons</groupId> <artifactId>jaxb2-basics-annotate</artifactId> <version>0.6.0</version> </plugin> <plugin> <groupId>org.jvnet.jaxb2_commons</groupId> <artifactId>jaxb2-namespace-prefix</artifactId> <version>1.1</version> </plugin> </plugins> </configuration> </plugin>
项目B的pom.xml插件
<plugin> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> <version>0.8.1</version> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>generate</goal> </goals> </execution> </executions> <configuration> <args> <arg>-Xannotate</arg> <arg>-Xnamespace-prefix</arg> <arg>-nv</arg> </args> <extension>true</extension> <forceRegenerate>true</forceRegenerate> <bindingDirectory>${basedir}/src/main/resources/xjb</bindingDirectory> <bindingIncludes> <include>*.xjb</include> </bindingIncludes> <schemas> <schema> <fileset> <directory>${basedir}/src/main/resources/xsd/</directory> <includes> <include>B.xsd</include> </includes> </fileset> </schema> <schema> <dependencyResource> <groupId>AgroupID</groupId> <artifactId>AartifactID</artifactId> <resource>xsd/A.xsd</resource> </dependencyResource> </schema> </schemas> <episodes> <episode> <groupId>AgroupID</groupId> <artifactId>AartifactID</artifactId> </episode> </episodes> <debug>true</debug> <verbose>true</verbose> <plugins> <plugin> <groupId>org.jvnet.jaxb2_commons</groupId> <artifactId>jaxb2-basics</artifactId> <version>0.6.2</version> </plugin> <plugin> <groupId>org.jvnet.jaxb2_commons</groupId> <artifactId>jaxb2-basics-annotate</artifactId> <version>0.6.2</version> </plugin> <plugin> <groupId>org.jvnet.jaxb2_commons</groupId> <artifactId>jaxb2-namespace-prefix</artifactId> <version>1.1</version> </plugin> </plugins> </configuration> </plugin>
您必须在项目B之前执行项目A的mvn安装
添加此插件以添加到源目标生成的类
<plugin> <groupId>org.prehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.1</version> <executions> <execution> <id>add-source</id> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>target/generated-sources/xjc</source> </sources> </configuration> </execution> </executions> </plugin>
记得执行Maven-更新项目
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)