[英]How can I generate classes from XSD that includes another XSD
我有2个项目:
xsdproject/
src/main/resources/
a.xsd
b.xsd
implproject/
在implproject中,我想使用maven-jaxb2-plugin从xsd生成类。
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<cleanPackageDirectories>true</cleanPackageDirectories>
<forceRegenerate>true</forceRegenerate>
<schemas>
<schema>
<dependencyResource>
<groupId>some.group</groupId>
<artifactId>xsdproject</artifactId>
<version>${project.version}</version>
<resource>a.xsd</resource>
</dependencyResource>
</schema>
<schema>
<dependencyResource>
<groupId>some.group</groupId>
<artifactId>xsdproject</artifactId>
<version>${project.version}</version>
<resource>b.xsd</resource>
</dependencyResource>
</schema>
</schemas>
</configuration>
</plugin>
问题来了 - > b.xsd有
<xs:include schemaLocation="a.xsd" />
在生成过程中我有一个错误:
Failed to read schema document 'a.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
有没有办法成功导入2 XSD并编译它们?
免责声明。 我是maven-jaxb2-plugin
。
请尝试以下方法:
src/main/resources/catalog.cat
:
REWRITE_SYSTEM "a.xsd" "maven:some.group:xsdproject:jar::!/a.xsd"
在pom.xml
的configuration
中
<catalog>src/main/resource/catalog.cat</catalog>
(请参阅使用目录 。)
我还认为你只需要编译b.xsd
。 应自动包含a.xsd
。
如果出现问题,请运行mvn -X clean install
并检查日志。
也可以看看:
如果您需要进一步的支持,请提交问题并提供示例项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.