栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

jaxb,xsd导入无法识别

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

jaxb,xsd导入无法识别

我使用此插件来解决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-更新项目



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/515653.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号