The basic annotation for a field that's intended to be an element is XmlElement. It permits you to define the XML element name, the namespace, whether it is optional or nillable, a default value and the Java class. Here are two annotated fields, and…
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean o…
This annotation adds information that would be available from a schema type, but isn't implied by a Java class declaration. The annotation has several attributes: factoryClass and factoryMethod define the class containing a no-argument method for cre…
If JAXB binds a class to XML, then, by default, all public members will be bound, i.e., public getter and setter pairs, or public fields. Any protected, package-visible or private member is bound if it is annotated with a suitable annotation such as …
A class that describes an XML element that is to be a top-level element, i.e., one that can function as an XML document, should be annotated with XmlRootElement. Its optional elements are name and namespace. By default, the class name is used as the…
For some Java container types JAXB has no built-in mapping to an XML structure. Also, you may want to represent Java types in a way that is entirely different from what JAXB is apt to do. Such mappings require an adapter class, written as an extensio…
The annotation XmlSchemaType defines a mapping between an arbitrary Java type and a simple schema built-in type. Most of the time the default mapping is satisfactory, but every now and then an alternative may be more convenient. Let's assume that the…
This annotation can only be used with a package. It defines parameters that are derived from the xsd:schema element. It must be written on a file package-info.java situated in the package. Below is an example, specifying the namespace and elementForm…
Provided that XML lets you represent a data item as a single value, there is no cut-and-dried rule for deciding between using an element or an attribute. (If you look for guidance, the schema describing the XML Schema language itself, making judiciou…
To be able to create objects from XML elements, the unmarshaller must have an object factory with methods for creating all sorts of objects. Therefore, each package containing JAXB classes must contain one class ObjectFactory, annotated with XmlRegis…