jaxb.properties missing at runtime when built with Maven

后端 未结 3 1075
渐次进展
渐次进展 2021-01-11 18:47

I have a project where I want to work with a set of Classes generated by JAXB from an XSD. With these classes I would like to marshall/unmarshall from XML and JSON.

<
相关标签:
3条回答
  • 2021-01-11 19:14

    You need to make sure the jaxb.properties file is under the resources directory in the same package structure as the corresponding model classes.

    Example

    • https://github.com/bdoughan/blog20110322
    0 讨论(0)
  • Example, in maven the java class

     src\main\java\com\example\sitemap\generate\domain
    

    and the file jaxb.properties

     src\main\resources\com\example\sitemap\generate\domain\jaxb.properties
    
    0 讨论(0)
  • 2021-01-11 19:22

    Use it as a System property, if it is cumbersome to add jaxb.properties files for each and every java packages where JAXB pojo classes are present.

    System.setProperty("javax.xml.bind.JAXBContextFactory", "org.eclipse.persistence.jaxb.JAXBContextFactory");
    
    0 讨论(0)
提交回复
热议问题