javax.xml.bind.PropertyException: name: eclipselink.id-resolver value:   com.persistence.MyIDResolver@4ab34646
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.setProperty(AbstractUnmarshallerImpl.java:332)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.setProperty(UnmarshallerImpl.java:444)


伙计们,我正在使用以下代码获取此属性异常:

jaxbUnmarshaller.setProperty(UnmarshallerProperties.ID_RESOLVER, new MyIDResolver());


请帮助我,我不知道我在做什么错!!!

最佳答案

首先,确定要使用自定义IDResolver吗?使用标准的JAXB (JSR-222)键用@XmlID注释,外键用@XmlIDREF注释,并且所有连接都自动为您完成。


http://blog.bdoughan.com/2010/10/jaxb-and-shared-references-xmlid-and.html


UnmarshallerProperties.ID_RESOLVEREclipseLink JAXB (MOXy)的属性,您需要确保使用MOXy作为JAXB提供程序来使用它。


http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as-your.html


如果您使用的是JDK中包含的JAXB版本,则可以使用以下属性:

com.sun.xml.internal.bind.IDResolver


如果使用的是JAXB参考实现,则可以使用以下属性:

com.sun.xml.bind.IDResolver

09-10 07:11
查看更多