具体方法:
1. 在jaxb的setClasstobebounds中,只需要子类的class,无需父类。
2. 父类的前面加如下声明:
@XmlAccessorType(XmlAccessType.FIELD)@XmlSeeAlso({ 子类.class})public class 父类 extends Entity{ @XmlElement public String platformid; @XmlElement public String pointid; public String getPlatformid() { return platformid; } public void setPlatformid(String platformid) { this.platformid = platformid == null ? null : platformid.trim(); } public String getPointid() { return pointid; } public void setPointid(String pointid) { this.pointid = pointid == null ? null : pointid.trim(); }}
3. 子类如下:
@XmlAccessorType(XmlAccessType.FIELD)@XmlRootElement(name="parameters")public class TPointInfo extends TPointInfoKey{ @XmlElement private String pointname; @XmlElement private String longitude; @XmlElement private String latitude; @XmlElement private String groupid; public String getPointname() { return pointname; } public void setPointname(String pointname) { this.pointname = pointname == null ? null : pointname.trim(); } public String getLongitude() { return longitude; } public void setLongitude(String longitude) { this.longitude = longitude == null ? null : longitude.trim(); } public String getLatitude() { return latitude; } public void setLatitude(String latitude) { this.latitude = latitude == null ? null : latitude.trim(); } public String getGroupid() { return groupid; } public void setGroupid(String groupid) { this.groupid = groupid == null ? null : groupid.trim(); }}