Pedro Barros
Pedro Barros

Reputation: 1336

How to apply a @XmlJavaTypeAdapter rule to all fields of a specific type at once in JAXB?

I want to change the way XML date format is written, but I don't want to put annotations in every getter of the entire project.

Is there a way to set the XmlAdapter globally to all fields of a specific type? Or at least in each class and not in each method.

Obs: My models aren't generated, they are hand written.

Thanks!

Upvotes: 1

Views: 681

Answers (1)

bdoughan
bdoughan

Reputation: 149047

You can set the @XmlJavaTypeAdapter at the package level and have it apply to all mapped fields/properties in domain classes in that package. This is done on a special package-info class.

Upvotes: 1

Related Questions