JaxbRepresentation gives error “doesnt contain ObjectFactory.class or jaxb.index”

后端 未结 8 1276
再見小時候
再見小時候 2021-02-02 08:11

I am trying to create a sample test application which converts an object to JaxbRepresentation. But when I try to run this, it gives me an error.

Main.java file

相关标签:
8条回答
  • 2021-02-02 09:08

    Use the complete package name of the where the ObjectFactory class is present to declare and instantiate the Object.

    0 讨论(0)
  • 2021-02-02 09:12

    To get rid of additional jaxb.index files you may use Java class to instantiate the context:

    http://docs.oracle.com/javase/6/docs/api/javax/xml/bind/JAXBContext.html#newInstance(java.lang.Class...)

    Usually you need to pass in only single java class because other classes are "statically reachable from these class(es)" so JAXB is able to identify them.

    0 讨论(0)
提交回复
热议问题