如何在 MOXy 中使用实例化的 XmlAdapter?

How to use instantiated XmlAdapter in MOXy?

在不使用 MOXY 的情况下使用 JAXB 时,我按如下所示进行了 Unmarshal。

          Unmarshaller u = this.jaxbContext.createUnmarshaller();
          u.setAdapter(new Something.JaxbAdapter(this, ...));

但是,使用MOXy的JAXBContextFactory时,createContext时出现错误

因为@XmlJavaTypeAdapter(Something.JaxbAdapter.class).

this.jaxbContext = org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(classes.toArray(new Class[0]), Collections.emptyMap());

错误:

Exception [EclipseLink-50063] (Eclipse Persistence Services - 3.0.2.v202107160933): org.eclipse.persistence.exceptions.JAXBException
Exception Description: An exception occurred while attempting to instantiate XmlAdapterClass [....Somegh$JaxbAdapter]. A possible cause is that the adapter class has no zero argument constructor.
Internal Exception: java.lang.InstantiationException: ....Somegh$JaxbAdapter

如何在MOXy中使用实例化的XmlAdapter?

MOXY 做不到这一点。

我使用 spring-oxm 的 Jaxb2Marshaller 而不是 MOXy 来让它工作。