JAXB: 2 cargos de IllegalAnnotationExceptions
Ésta es mi clase Analizador
public class Test {
public static void main(String args[]) throws Exception {
File file = new File("D:\\Test.xml");
JAXBContext jaxbContext = JAXBContext.newInstance(MyOrder.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
MyOrder customer = (MyOrder) jaxbUnmarshaller.unmarshal(file);
System.out.println(customer.getOrder().getSide());
}
}
Ésta es MyOrder.java presentar
@XmlRootElement(name = "BXML")
public class MyOrder {
@XmlElement(name = "Bag")
protected Order order;
public MyOrder() {
}
@XmlAttribute
public Order getOrder() {
return order;
}
public void setOrder(Order order) {
this.order = order;
}
}
Ésta es mi objeto de dominio (Order.java)
@XmlRootElement(name = "BXML")
public class Order {
public Order() {
}
@XmlAttribute(name = "Side")
protected BigInteger Side;
@XmlValue
public BigInteger getSide() {
return Side;
}
public void setSide(BigInteger side) {
Side = side;
}
}
Esta es la excepción que estoy recibiendo cuando traté de ejecutar el programa
Exception in thread "main" com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
@XmlAttribute/@XmlValue need to reference a Java type that maps to text in XML.
this problem is related to the following location:
at public com.Order com.MyOrder.getOrder()
at com.MyOrder
Class has two properties of the same name "order"
this problem is related to the following location:
at public com.Order com.MyOrder.getOrder()
at com.MyOrder
this problem is related to the following location:
at protected com.Order com.MyOrder.order
at com.MyOrder
Hola, no pude capaz de resolver el problema de unión, i enviado en el correo, cualquier ayuda ? – Pawan
¿Ha definido la asignación de otros elementos ('', '', ...)? Si desea capturar solo una parte de XML, marque [aquí] (http://stackoverflow.com/questions/8526002). –