使用 Moxy 作为默认的 JAXB 实现 [英] Use Moxy as default JAXB Implementation

查看:24
本文介绍了使用 Moxy 作为默认的 JAXB 实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了使用 Moxy 作为 JAXB 实现,必须在包含应用程序域类的文件夹中添加一个名为 jaxb.properties 的文件,并包含以下行

In order to use Moxy as JAXB Implementation, one has to add a file called jaxb.properties in the folder with the domain classes of the application and include the following line

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

是否可以将 moxy 设为项目的默认值?如果我有许多不同的文件夹,其中包含带注释的域类,我应该将这个文件放在哪个文件夹中?

Is it possible to make moxy the default for the project ? In case I have many different folders with annotated domain classes in which folder should I put this file?

推荐答案

注意:我是EclipseLink JAXB (MOXy) 领导和成员 JAXB (JSR-222) 专家组.

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

MOXy 已经是 WebLogic 12.1.1 中的默认 JAXB 实现:

MOXy is already the default JAXB implementation in WebLogic 12.1.1:

在其他环境中,您还可以利用 META-INF/services 机制将 MOXy 指定为默认的 JAXB 提供程序:

In other environments you could also leverage the META-INF/services mechanism to specify MOXy as the default JAXB provider:

  1. 在目录META-INF/services
  2. 中创建一个包含名为javax.xml.bind.JAXBContext的文件的JAR
  3. javax.xml.bind.JAXBContext文件的内容必须是org.eclipse.persistence.jaxb.JAXBContextFactory
  4. 将该 jar 添加到您的类路径中.
  1. Create a JAR that contains a file called javax.xml.bind.JAXBContext in the directory META-INF/services
  2. The contents of the javax.xml.bind.JAXBContext file must be org.eclipse.persistence.jaxb.JAXBContextFactory
  3. Add that jar to your classpath.

这篇关于使用 Moxy 作为默认的 JAXB 实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆