Java 从EURID提供的*.xsd生成模型时发生JAXB异常(EPP协议)
我试图从EurID提供的*.xsd文件生成Java代码 目前我收到了几个例外情况:Java 从EURID提供的*.xsd生成模型时发生JAXB异常(EPP协议),java,xml,maven,jaxb,xsd,Java,Xml,Maven,Jaxb,Xsd,我试图从EurID提供的*.xsd文件生成Java代码 目前我收到了几个例外情况: Error while parsing schema(s).Location [ file:~/src/main/resources/epp-1.0.xsd{375,32}]. org.xml.sax.SAXParseException; systemId: file:~/src/main/resources/epp-1.0.xsd; lineNumber: 375; columnNumber: 32; src-
Error while parsing schema(s).Location [ file:~/src/main/resources/epp-1.0.xsd{375,32}].
org.xml.sax.SAXParseException; systemId: file:~/src/main/resources/epp-1.0.xsd; lineNumber: 375; columnNumber: 32; src-resolve: Cannot resolve the name 'eppcom:minTokenType' to a(n) 'type definition' component.
[ERROR] Error while parsing schema(s).Location [ file:~/src/main/resources/nsgroup-1.0.xsd{86,42}].
org.xml.sax.SAXParseException; systemId: file:~/src/main/resources/nsgroup-1.0.xsd; lineNumber: 86; columnNumber: 42; src-resolve: Cannot resolve the name 'euridcom:nsgType' to a(n) 'type definition' component.
[ERROR] Error while parsing schema(s).Location [ file:~/src/main/resources/domain-1.0.xsd{94,53}].
org.xml.sax.SAXParseException; systemId: file:~/src/main/resources/domain-1.0.xsd; lineNumber: 94; columnNumber: 53; src-resolve: Cannot resolve the name 'host:addrType' to a(n) 'type definition' component.
Maven插件配置如下所示:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.3</version>
<configuration>
<schemaDirectory>src/main/resources</schemaDirectory>
<bindingDirectory>src/main/resources</bindingDirectory>
<bindingIncludes>
<include>bindings.xml</include>
</bindingIncludes>
<extension>true</extension>
<debug>true</debug>
<args>
<arg>-extension</arg>
<arg>-Xnamespace-prefix</arg>
</args>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-namespace-prefix</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
</plugin>
org.jvnet.jaxb2.maven2
eppcom.xsd在这里:
我已经花了5天的时间试图找出问题所在——尝试maven插件选项的不同组合等等。
SO社区是我现在最后的机会。
提前感谢您的提示。我被xsd改变了。添加属性schemaLocation以导入所有xsd模式中的元素。然后类的生成就可以了
如果我使用catalog来解析名称空间,那么我在某些元素的双重定义方面会遇到问题。我使用的JRE/JDK不知何故并不完整。用JavaEE安装JDK解决了JaxB的问题。我尝试用epp-1.0.xsd()验证xml并替换
<import namespace="urn:ietf:params:xml:ns:eppcom-1.0"/>
在epp-1.0.xsd文件中,使用
<import namespace="urn:ietf:params:xml:ns:eppcom-1.0" schemaLocation="http://www.iana.org/assignments/xml-registry/schema/eppcom-1.0.xsd"/>
解决了这个问题
<import namespace="urn:ietf:params:xml:ns:eppcom-1.0" schemaLocation="http://www.iana.org/assignments/xml-registry/schema/eppcom-1.0.xsd"/>