【发布时间】:2017-11-27 05:30:50
【问题描述】:
我正在生成使用 xsd 分类的模型,以下是我的 xsd 文件之一,我正在使用它生成 Generator 模型,这里我的问题是我想要其中一个变量的类型是 Long 类类型但是我得到了long premitive 数据类型。
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc" jaxb:version="1.0">
<xsd:complexType name="Generator">
<xsd:sequence>
<xsd:element name="id" type="xsd:string" minOccurs="1" />
<xsd:element name="name" type="xsd:string" minOccurs="1" />
<xsd:element name="age" type="xsd:int" minOccurs="1" />
<xsd:element name="timestamp" type="xsd:long" minOccurs="1" />
</xsd:sequence>
</xsd:complexType>
生成的类是这样的:-
public class Generator
implements Cloneable, CopyTo, Equals, ToString
{
@XmlElement(required = true)
protected String id;
@XmlElement(required = true)
protected String name;
@XmlElement(required = true)
protected int age;
@XmlElement(required = true)
protected long timestamp;
// settter and getter methods
}
生成的timestamp 值是long 类型,但我希望它是Long 类型
【问题讨论】: