简体   繁体   中英

How can I Specify MOXy JAXB as my Apache CXF implementation for Apache CXF 2.2.6

如何告诉Apache CXF使用MOXy JAXB?

Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group.

For JAX-RS applications in Apache CXF it may be enough to add a jaxb.properties file in the same package as your domain model specifying MOXy as the JAXB (JSR-222) provider ( http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as-your.html ) with the following entry:

javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory

This is all that is required when creating a JAX-RS application using Jersey .

It seems to me that Apache CXF uses org.apache.cxf.databinding.JAXBDataBinding class as the primary means of allowing potential overrides. I saw your solution titled "Specifying EclipseLink MOXy as Your JAXB Provider". It seems if I understand it right, that I might have to put this properties file in every package that has a JAXB class. Is that a correct assumption?

The jaxb.propertie file needs to be in at least one of the packages used to create the JAXBContext .

Coming in EclipseLink 2.5

Similar to the MOXyJsonProvider class we added in EclipseLink 2.4 to make it easy to configure MOXy as your JSON provider (see: http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html ), in EclipseLink 2.5 we are adding MOXyXmlProvider to make it easy to use MOXy as your XML provider in environments where simply adding the jaxb.properties file doesn't work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM