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:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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; | |
} |