MOXy在2.6.0版本中是否支持非字符串@XmlID?

Ste*_*vra 6 java json jaxb marshalling moxy

根据https://gist.github.com/VineetReynolds/5108580,JAXB规范要求注释的元素@XmlIDString.MOXy在2.5.x版本中没有强制执行此操作.但是,
对于2.6.0版本,它似乎不再受支持了.

[Exception [EclipseLink-50016] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.JAXBException
Exception Description: Property [id] has an XmlID annotation but its type is not String.]**strong text**
Run Code Online (Sandbox Code Playgroud)

这是一种想要的行为,还是一种不必要的回归?

从MOXy 2.5.x迁移时,避免此类错误的正确方法是什么?
是否@XmlJavaTypeAdapter按照本文中的描述使用JAXB编组一个长基本类型,这也影响了对象本身(及其ID)如何序列化为JSON的方式(例如,类型的id字段Long变为json字符串?

小智 6

是的,它仍然受到支持.在2.6.0中,默认情况下不支持,但必须通过@XmlIDExtension注释启用.

https://eclipse.org/eclipselink/releases/2.6.php

只是用给定的字段注释@XmlIDExtension.还可以指定系统属性org.eclipse.persistence.moxy.annotation.xml-id-extension以全局覆盖默认行为.