Do you always need an ObjectFactory class when using JAXB?

前端 未结 3 1639
后悔当初
后悔当初 2020-12-24 09:05

Do you always need an ObjectFactory class when using JAXB?

Without it I get this exception:

javax.xml.bind.JAXBException: \"com.a.b.c\"

3条回答
  •  一个人的身影
    2020-12-24 09:24

    I was using Spring and I just had to change

    Jaxb2Marshaller mlr = new Jaxb2Marshaller();
    mlr.setContextPaths("","");
    

    to

    Jaxb2Marshaller mlr = new Jaxb2Marshaller();
    mlr.setPackagesToScan("","");
    

提交回复
热议问题