简体   繁体   中英

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM