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

后端 未结 8 1472
再見小時候
再見小時候 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

    If you have an instantiation of your object factory like

    private ObjectFactory of;
    

    ..then the safest, most reliable way to get a Context to Marshall with is:

      JAXBElement gl = of.createGreetings( grList );
      JAXBContext jc = JAXBContext.newInstance(of.getClass());
      Marshaller m = jc.createMarshaller();
    

提交回复
热议问题