Bublik
Bublik

Reputation: 922

Jaxb when use jaxb.index file

I was investigating object marshaling and unMarshaling using JAXB. while noticed that there is two option of getting an instance of JAXBContext.

For the second way, you have to provide jaxb.index file, containing list of bean class names.

Maybe someone can explain, what is the difference between this two methods of getting JAXBContext instance? Which is better to use and when?

Upvotes: 1

Views: 2558

Answers (1)

lexicore
lexicore

Reputation: 43651

For the second way, you have to provide jaxb.index file, containing list of bean class names.

This is not correct. In JAXB2 this works without jaxb.index as well, the classes are "recognized" via ObjectFactory and @XmlSeeAlso.

The usual approach is to use JAXBContext context = JAXBContext.newInstance("my.package:my.another.package); as you normally want to consider all of the relevant classes and don't want to enumerate them explicitly.

Upvotes: 2

Related Questions