gpt4 book ai didi

java - JAXB 编译器正在绑定(bind) xs :boolean to Java boolean instead of Boolean wrapper class

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:13:51 25 4
gpt4 key购买 nike

我在我的项目中使用 jaxb2-maven-plugin ver 1.5 从 XSD 生成 Java 类。我的 XSD 看起来像:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="ClientRQ">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="ClientID" minOccurs="1" maxOccurs="1"/>
<xs:element type="xs:boolean" name="Complimentary" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
<xs:attribute type="xs:string" name="Version"/>
<xs:attribute type="xs:dateTime" name="TimeStamp"/>
</xs:complexType>
</xs:element>
</xs:schema>

反序列化为 Java 类后,我收到 boolean complimentary 字段,但我需要有 Boolean我无法编辑 XSD,因为它是公开的。有谁知道如何在不改变方案的情况下解决这个问题?

最佳答案

jaxb2-maven-plugin 1.5 版本很旧。更新到最新版本,看看是否还有这个问题。

<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.3</version>
</dependency>

关于java - JAXB 编译器正在绑定(bind) xs :boolean to Java boolean instead of Boolean wrapper class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39596124/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com