我有一个声明Joda时间DateTime
字段的类。JAXB为@XmlTransient字段抛出零参数构造函数错误
但是,这个值不是由unmarhsalling进程设置的,而是稍后在afterUnmarhsal
方法中设置的。
因此,本场被标记为XmlTransient
:
@XmlTransient
private DateTime startTime;
但是,试图启动的时候,我碰到这样的错误:
javax.xml.bind.JAXBException: Exception Description: The class org.joda.time.DateTime$Property requires a zero argument constructor or a specified factory method. Note that non-static inner classes do not have zero argument constructors and are not supported. - with linked exception: [Exception [EclipseLink-50001] (Eclipse Persistence Services - 2.2.0.v20110202-r8913) ...
为什么要JAXB关心这个类,考虑到这是明显的短暂的反编组& unmarshalling的目的?
如何让JAXB忽略该字段?我知道我可以在那里放置一个工厂方法,但它似乎没有意义,因为工厂将无法实例化该值(这就是为什么它在afterUnmarshal
中完成)
这个错误听起来很熟悉(我会调查)。你有没有尝试过一个更新的版本,目前的版本是2.3.2:http://www.eclipse.org/eclipselink/downloads/ – 2012-03-07 23:33:04
@BlaiseDoughan谢谢你的跟进,以及最新版本的headup。刚试过2.3.2('2.3.2.v20111125-r10461'),并得到相同的错误。 FYI - [The Maven Page](http://wiki.eclipse.org/EclipseLink/Maven#Available_Released_Versions)已过期,仅列出了2.2.0版本(这是我错过的版本)。 – 2012-03-08 05:03:00
我发布了一个答案(http://stackoverflow.com/a/9619140/383861)并更新了wiki页面(http://wiki.eclipse.org/EclipseLink/Maven#Available_Released_Versions)。 – 2012-03-08 14:31:21