문제

Image you've got auto generated beans and you want to extend them with some extra functionality. So you extend the auto generated beans and in the same file you also extend the ObjectFactory and annotate it with @XmlRegistry.

When unmarshalling some object the extended ObjectFactory ins't used and therefore the auto generated beans are created.

What step am I missing to get my custom beans created? Can I tell JAXB which Factory to use? Or does JAXB not use the factory at all?

도움이 되었습니까?

해결책

Yes, you need to specify the ObjectFactory when configuring your Unmarshaller. I think you can use something like this to provide your own ObjectFactory implemenation:

unmarshaller.setProperty("com.sun.xml.bind.ObjectFactory",new MyObjectFactory());
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top