Unable to understand JAXB Unmarshalling behaviour

前端 未结 1 933
我在风中等你
我在风中等你 2021-01-23 00:31

Reference to my previous post. I have following code which is reading XML from the file.

logger.log(Level.INFO, \"testSchemaChange\");
JAXBContext jaxbContext =          


        
相关标签:
1条回答
  • 2021-01-23 01:21

    The problem you are seeing is because the JAXBContext isn't aware of your ObjectFactory class that contains the @XmlElementDecl annotation for the book element.

    When you create a JAXBContext on a package name, the it will automatically pull in the ObjectFactory class. If you create a JAXContext on classes you need to explicitly include the class with the @XmlRegistry annotation (ObjectFactory in this case).

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