Hello!
I have
@XmlAttribute(required=true)
in hundreds places in a projects.
Can I make this default?...
...So that I then only need to specify
@XmlAttribute(required=false)
when needed.
Hello!
I have
@XmlAttribute(required=true)
in hundreds places in a projects.
Can I make this default?...
...So that I then only need to specify
@XmlAttribute(required=false)
when needed.
No, that behaviour is hard-wired. However, the required
attribute is really a lightweight alternative to a proper XML schema. If you need better control over document validation, then I suggest you define an XML Schema for your documents, and inject the schema into the JAXBContext
. The documents will then be checked on marshalling and unmarshalling, and you won't have to rely on the annotations for validation.