使用@XMLJavaTypeAdapters进行JAXB解组

使用@XMLJavaTypeAdapters进行JAXB解组,java,jaxb,Java,Jaxb,我有三节课 @XmlRootElement public class GeofenceParameter{ private GeofenceCenterAddress geofenceCenterAddress; private GeofenceCenterCoordinates geofenceCenterCoordinates; } public class GeofenceCenterAddress extends GeofenceParameter{ } pu

我有三节课

@XmlRootElement
public class GeofenceParameter{

    private GeofenceCenterAddress geofenceCenterAddress;

    private GeofenceCenterCoordinates geofenceCenterCoordinates;
}

public class  GeofenceCenterAddress extends GeofenceParameter{

}

public class  GeofenceCenterCoordinate extends GeofenceParameter{

}
我制作了两个不同的XmlAdapter扩展类,用于marshall和unmarshall GeofenceCenterAddress和GeoFenceCenterEcoCoordinate中的Geofence参数

Class forGeofenceCenterCoordinate extends XmlAdapter<ValueType,BoundType>{
}

Class forGeofenceCenterAddress extends XmlAdapter<ValueType,BoundType>{
}
类forGeofenceCenterCoordinate扩展了XmlAdapter{
}
类forGeofenceCenterAddress扩展了XmlAdapter{
}
用于根据Soap请求从GeoFenceParameter获取关联到GeofenceCenterAddress或GeofenceCenterCoordinate类的实例

为此,我在package-info.java文件
@XmlJavaTypeAdapters{(@XmlJavaTypeAdapter(type=forGeofenceCenterCoordinate)),@XmlJavaTypeAdapter(type=forGeofenceCenterAddress)}

但在Web服务中,它将给我在注释中首先指定的类的实例,即这个
@XmlJavaTypeAdapter(type=forGeofenceCenterCoordinate)类的实例,而不是来自GeoFenceParameter的@XmlJavaTypeAdapter(type=forGeofenceCenterAddress)

你能帮我在JAXB继承编组和解编组中定位第二个类的实例吗


提前感谢

我不记得使用过
@XmlJavaTypeAdapters
,但是
@XmlJavaTypeAdapter
注释的正常用法只是
@XmlJavaTypeAdapter(forGeofenceCenterCoordinate.class)

只有在包级别应用注释时,类型参数才是必需的