0
JAXB生成後我有一個包含我的int數組的錯誤類型的類,它使用Integer類型而不是int []來註釋它。JAXB生成後錯誤的註釋類型
這裏是我的XSD:
<complexType name="GenericChartTask">
<sequence>
<element name="clients" type="struct:IDNameSiteServiceImageIndex"
maxOccurs="unbounded" minOccurs="0">
</element>
<element name="commonTasks" type="struct:NameAndID"
maxOccurs="unbounded" minOccurs="0">
</element>
<element name="groups" type="int" maxOccurs="unbounded"
minOccurs="0"></element>
<element name="siteServices" type="struct:SiteService"
maxOccurs="unbounded" minOccurs="0">
</element>
</sequence>
</complexType>
這裏是我代後得到:
public class GenericChartTask {
@XmlElement(namespace = "http://american-data.com/ecs/struct")
protected ad.ecs.struct.IDNameSiteServiceImageIndex[] clients;
@XmlElement(namespace = "http://american-data.com/ecs/struct")
protected ad.ecs.struct.NameAndID[] commonTasks;
@XmlElement(namespace = "http://american-data.com/ecs/struct", type = Integer.class)
protected int[] groups;
@XmlElement(namespace = "http://american-data.com/ecs/struct")
protected ad.ecs.struct.SiteService[] siteServices;
...
我也有一個結合,生成陣列,而不是名單,因爲JAXB沒有按」不想生成合法的bean(它會刪除列表中的setter)。
<jxb:bindings node="//xs:element[@name='groups']">
<jxb:property collectionType="indexed" />
</jxb:bindings>
我的問題是,有沒有什麼辦法來擺脫故障部件類型= Integer.class的?因爲當我想爲我的JSON反序列化這個對象時它引發了問題。
生病試試這個,讓你知道 – serge
這並沒有幫助 - 仍然會產生錯誤的類型 – serge
嘗試滴的maxOccurs也 – Revive