Ble*_*eek 6 java binding jaxb xjc
应避免以下讨论。这个问题不是什么:
题:
我想要一个jaxb绑定声明的示例来覆盖xs:integer到Java BigInteger的默认映射,以便xjc会改为生成Java Integer。
例如
<xs:attribute name="id" type="xs:integer"/>
Run Code Online (Sandbox Code Playgroud)
应该产生
@XmlAttribute(name = "id")
Integer id;
Run Code Online (Sandbox Code Playgroud)
并不是
@XmlAttribute(name = "id")
BigInteger id;
Run Code Online (Sandbox Code Playgroud)
您可以将以下内容添加到您的绑定文件中:
<globalBindings>
<javaType xmlType="xs:integer" name="java.lang.Integer"/>
</globalBindings>
Run Code Online (Sandbox Code Playgroud)
这将产生,例如:
@XmlAttribute(name = "id")
@XmlJavaTypeAdapter(Adapter1 .class)
protected Integer id;
public int getId() {
if (id == null) {
return new Adapter1().unmarshal("0");
} else {
return id;
}
}
public void setId(Integer value) {
this.id = value;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2456 次 |
| 最近记录: |