我是 Jaxb 插件来生成模型的新手。我有 2 个 xsd 文件,其中一个 xsd 引用其他 xsd 中的类型
常见的.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://www.example.com/schemas/common"
version="1.0" xmlns="http://www.example.com/schemas/common"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="person">
<xsd:sequence>
<xsd:element minOccurs="1" name="gender" type="xsd:string"/>
<xsd:element minOccurs="1" name="dateOfBirth" type="xsd:string"/>
<xsd:element minOccurs="1" name="name" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
瞳孔.xsd ,这引用了 common.xsd中定义的人
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://www.example.com/schemas/pupil" version="1.0"
xmlns:common="http://www.example.com/schemas/common"
xmlns="http://www.example.com/schemas/pupil" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.example.com/schemas/common" schemaLocation="http://www.example.com/domain/schemas/common/common.xsd"/>
<xsd:complexType name="student">
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="class" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="1" name="generralInfo" type="common:person"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
catalog.cat,尝试使用插件的剧集功能
REWRITE_SYSTEM " http://www.example.com/domain/schemas/common/common.xsd " "."
pom.xml,这是我的 Maven 构建配置
<build>
<defaultGoal>test</defaultGoal>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<configuration>
<extension>true</extension>
<catalog>src/main/resources/catalog.cat</catalog>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
当我跑步时mvn clean install
,我得到以下
错误
[错误] 解析架构时出错。位置 [ http://www.example.com/domain/schemas/common/common.xsd {XXX,XX}]。org.xml.sax.SAXParseException;系统ID: http ://www.example.com/domain/schemas/common/common.xsd ;行号:XXX;列号:XXX;'person' 已经定义
我尝试使用此处提到的各种选项来解决此错误,但这对我有帮助。我认为我在绑定配置或 pom 配置中做错了什么
有人能指出这里有什么问题吗