java - jaxb2-maven-plugin -- com.sun.istack.SAXParseException2:属性“类型”已定义。使用 <jaxb:property> 解决此冲突
问题描述
我正在使用 jaxb2-maven-plugin 从 XSD 文件构建 java 类。我在 Maven 构建期间遇到错误,表明“类型”属性存在命名冲突
[ERROR] file:/Users/me/Documents/workspace/purchase-order-service/src/main/xsd/ProcessShipment.oagi9.xsd [1431,58]
com.sun.istack.SAXParseException2: Property "Type" is already defined. Use <jaxb:property> to resolve this conflict.
我相信要解决这个问题,我需要创建一个外部绑定文件来重命名属性。我查看了一些资源,但无法使其正常工作-同样的错误。似乎甚至没有检测到我的绑定文件。
pom.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>${jaxb2-maven.version}</version>
<executions>
...
<execution>
<id>xjc-processshipment</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<xjbSources>
<xjbSource>src/main/xsd/ProcessShipment.oagi9.xjb</xjbSource>
</xjbSources>
<sources>
<source>src/main/xsd/ProcessShipment.oagi9.xsd</source>
</sources>
<outputDirectory>${basedir}/target/generated-sources/process-shipment
</outputDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</execution>
</executions>
我试图转换为 Java 对象的 src/main/xsd/ProcessShipment.oagi9.xsd 文件可以在这里下载https://drive.google.com/file/d/10KoS9CeinUbOTQ5Nc2Gh9dmiS1eLxNs4/view?usp=sharing
我正在尝试使用 src/main/xjb/bindings.xjb 来修复映射冲突
<jxb:bindings version="1.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--
Change since version 2.0 of the j-m-p:
Note that the schemaLocation path must point to the XSD file
relative to *this* file, rather than the basedir.
-->
<jxb:bindings schemaLocation="../xsd/ProcessShipment.oagi9.xsd" node="//xsd:schema">
<jxb:bindings node="//xs:element[@ref='type']">
<jxb:property name="DeprecatedTypeAttribute"/>
</jxb:bindings>
<jxb:bindings node="//xs:element[@ref='Type']">
<jxb:property name="DeprecatedTypeAttribute"/>
</jxb:bindings>
</jxb:bindings>
</jxb:bindings>
谁能指出我正确的方向?我仍然遇到同样的错误,我认为这是因为我的 bindings.xjb 没有被拾取,而且我的绑定配置对于我正在尝试做的事情可能是错误的。感谢您的任何建议。
解决方案
推荐阅读
- ios - Xcode SpriteKit 游戏 - 如何在应用安装期间为多种屏幕尺寸配置 UI
- php - 内存泄漏 - 一个简单的 phpinfo() 页面会增加容器内存使用量
- android - 检查互联网
- javascript - React Native 条件渲染自定义卡片样式问题
- selenoid - 无法使用 docker 启动 selenoid 服务器
- javascript - Nodejs docx-merger 插件“Word 发现不可读的内容”
- react-native - 根据语言选择重新渲染当前视图
- javascript - 如何检查值是否存在于另一个属性 json 模式中
- html - Links are not clickable due to CSS?
- mysql - MYSQL - INSERT INTO table (column) VALUES (xxxx) WHERE column = 1;