@xmlschema jaxb package-info.java compilation error

I am trying to use annotations at the package level, but getting compilation from Eclipse.

I have a Head class with the following package / annotation:

  @javax.xml.bind.annotation.XmlSchema ( xmlns = { @javax.xml.bind.annotation.XmlNs(prefix = "com", namespaceURI="http://es.indra.transporte.common"), @javax.xml.bind.annotation.XmlNs( namespaceURI="http://www.w3.org/2001/XMLSchema") }, namespace = "http://es.indra.transporte.common", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED, attributeFormDefault = javax.xml.bind.annotation.XmlNsForm.UNQUALIFIED ) package es.indra.transporte.central.thalesinterface.common.beans; 

I created the package-info.java folder in es.indra.transporte.central.thalesinterface.common.beans with the above code, but I still get a compilation error

Annotations to packages should be in the package-info.java file

in Head class. I am using jdk6.

+4
source share
1 answer

The only problem I encountered while trying to compile your package information was that the @XmlNs annotation does not have a prefix property.

It:

 @javax.xml.bind.annotation.XmlNs( namespaceURI="http://www.w3.org/2001/XMLSchema") 

Must be:

 @javax.xml.bind.annotation.XmlNs(prefix="xsd", namespaceURI="http://www.w3.org/2001/XMLSchema") 

The following corrected code should compile:

 @javax.xml.bind.annotation.XmlSchema ( xmlns = { @javax.xml.bind.annotation.XmlNs(prefix = "com", namespaceURI="http://es.indra.transporte.common"), @javax.xml.bind.annotation.XmlNs(prefix="xsd", namespaceURI="http://www.w3.org/2001/XMLSchema") }, namespace = "http://es.indra.transporte.common", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED, attributeFormDefault = javax.xml.bind.annotation.XmlNsForm.UNQUALIFIED ) package es.indra.transporte.central.thalesinterface.common.beans; 

Example:

+2
source

Source: https://habr.com/ru/post/1337468/


All Articles