Check my JAXB implementation

最后都变了- 提交于 2019-12-23 03:00:19

问题


I am trying to use Eclipselink's MOXy. I put jaxb.properties file in the same directory as my annotated classes and it contains the entry:

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

Is there anyway I can be sure this implementation is being used at runtime? For example, I can check my StAX implementation is Woodstox by checking:

inputFactory.getClass().getName() is equal com.ctc.wstx.stax.WstxInputFactory

Is there anything similar I can do to check my JAXB implementation?

Thanks.


回答1:


From this answer:

package example;

import javax.xml.bind.JAXBContext;
import example.foo.Foo;

public class Demo {

    public static void main(String[] args) throws Exception{
        System.out.println(JAXBContext.newInstance(Foo.class).getClass());
        // If MOXy is used, this will print:
        // class org.eclipse.persistence.jaxb.JAXBContext
    }

}


来源:https://stackoverflow.com/questions/8626952/check-my-jaxb-implementation

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