Where to include jaxb.properties file?

风流意气都作罢 提交于 2019-11-30 17:17:25

You package the jaxb.properties file with your model classes. GlassFish does not include the MOXy bundle yet, but you can add it easily. Check out my blog for more info:

If you don't want or can not use the jaxb.properties (you have a lot of package, the model is in a external jar, you want only java and no configuration files...), you can directly specify the JaxbContextFactory :

Do not create the context using :

JAXBContext jaxbContext = JAXBContext.newInstance(new Class[]{Person.class, ObjectFactory.class}, properties);

But instead, specify the factory to use :

JAXBContext jaxbContext = JAXBContextFactory.createContext(new Class[]{Person.class, ObjectFactory.class}, properties);

where the factory is :

import org.eclipse.persistence.jaxb.JAXBContextFactory;

It is exactly the same, but it is specified explicitly in the java code instead of implicitly in a configuration file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!