//can prevent the field map to java bean property(UserId)
@XmlTransient
public String getAuthorId() {
return authorId;
}
//@XmlElement annotation can be used with the following program elements:
// a JavaBean property
// non static, non transient field
// within XmlElements
//Generally, if a class is annotated with @XmlRootElement, all the getters can be parsed to a child element of the class element.
//Sometimes, even if the getter is a method in a class that is annotated with @XmlRootElement, it may not be parsed to xml element.
//Adding this annotation can solve the problem.
@XmlElement//(required=true)
//@JsonSerialize(using=JsonDateSerializer.class)
public Date getPublishTime() {
return publishTime;
}
//The @XmlRootElement annotation can be used with the following program elements:
//a top level class
//an enum type
@XmlRootElement(name = "Book")
publicclass Book{}