JAXB : IllegalAnnotationExceptions - Class has two properties of the same name

Language/JAVA 2013. 7. 18. 17:30

just developing a test jaxb application and wanted to let getters and setters be created automatically with Lombok.
As I was attempting to assign annotations of private field members, got this exception:


Exception in thread "main" com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
Class has two properties of the same name "name"
this problem is related to the following location:
at public java.lang.String de.domain.jaxbtest.model.Book.getName()
at de.domain.jaxbtest.model.Book
at private java.util.List de.domain.jaxbtest.model.Bookstore.bookList
at de.domain.jaxbtest.model.Bookstore


the solution was easy as just adding @XmlAccessorType(XmlAccessType.FIELD) to defined class:

@Data
@XmlRootElement(name = "book")
@XmlAccessorType(XmlAccessType.FIELD)
public class Book {
@XmlElement(name = "title")
private String name;
private String author;
private String publisher;
private String isbn;
}



출처 - http://hoomb.blogspot.kr/2012/12/jaxb-illegalannotationexceptions-class.html

: