@xmlschema jaxb package-info.java 编译错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4828131/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
@xmlschema jaxb package-info.java compilation error
提问by Fran
I'm trying to use annotations at package level but I get compilation erros from Eclipse.
我正在尝试在包级别使用注释,但我从 Eclipse 得到编译错误。
I have a class Head
with the following package/annotation:
我有一个Head
带有以下包/注释的类:
@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 have created a package-info.java
in es.indra.transporte.central.thalesinterface.common.beans
folder with the above code but I'm still getting the compilation error
我用上面的代码创建了一个package-info.java
ines.indra.transporte.central.thalesinterface.common.beans
文件夹,但我仍然收到编译错误
Package annotations must be in file
package-info.java
包注释必须在文件中
package-info.java
in Head
class. I'm using jdk6.
在Head
课堂上。我正在使用 jdk6。
回答by bdoughan
The only problem I got when trying to compile your package info was that the @XmlNs annotation was missing the prefix property.
我在尝试编译包信息时遇到的唯一问题是 @XmlNs 注释缺少前缀属性。
This:
这:
@javax.xml.bind.annotation.XmlNs( namespaceURI="http://www.w3.org/2001/XMLSchema")
Should 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;
For an example see:
有关示例,请参见: