How can I avoid field from being serialized? I use xml attributes. Currently field has no attribute but gets to xml...
Annotate the field you want to exclude with @XmlTransient
.
Option #1 - Change the Accessor Type
By default a JAXB (JSR-222) implementation will treat all public fields and properties as being mapped. If you want to restrict this to just public properties then you can do the following:
@XmlAccessorType(XmlAccessType.PROPERTY)
public class Foo {
public int bar; // Not considered mapped if access type is set to PROPERTY
}
Option #2 - Specify the Field is Unmapped
You can mark a field/property with @XmlTransient
to prevent it from being mapped.
public class Foo {
@XmlTransient
public int bar; // Not considered mapped
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With