Java 2非法批注异常计数
我有一个Customer和CustomerFullAddress类,我正在使用JAXB尝试生成一个XML文件Java 2非法批注异常计数,java,xml,jaxb,Java,Xml,Jaxb,我有一个Customer和CustomerFullAddress类,我正在使用JAXB尝试生成一个XML文件 <Customer CustomerID="GREAL"> <CompanyName>Great Lakes Food Market</CompanyName> <ContactName>Howard Snyder</ContactName> <ContactTitle>Marketing M
<Customer CustomerID="GREAL">
<CompanyName>Great Lakes Food Market</CompanyName>
<ContactName>Howard Snyder</ContactName>
<ContactTitle>Marketing Manager</ContactTitle>
<Phone>(503) 555-7555</Phone>
<FullAddress>
<Address>2732 Baker Blvd.</Address>
<City>Eugene</City>
<Region>OR</Region>
<PostalCode>97403</PostalCode>
<Country>USA</Country>
</FullAddress>
</Customer>
而CustomerFullAddress是
package org.abc.customers;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlRootElement(name = "customerfulladdress")
//If you want you can define the order in which the fields are written
//Optional
@XmlType(propOrder = { "address", "city", "region", "postalCode", "country" })
public class CustomerFullAddress {
private String address;
...
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
.....
}
错误是
线程“main”中出现异常
com.sun.xml.internal.bind.v2.runtime.illegalannotations异常:2
IllegalAnnotationExceptions属性custAdd的计数存在,但
@XmlType.propOrder中未指定此问题与
以下地点:私人
org.abc.customers.CustomerFullAddress
org.abc.customers.Customer.custAdd地址
org.abc.customers.Customer属性custAddress存在,但不存在
在@XmlType.propOrder中指定此问题与
以下地点:公共场所
org.abc.customers.CustomerFullAddress
org.abc.customers.Customer.getCustAddress()位于
org.abc.customers.Customer
谢谢你看 来自JavaDoc,用于:
比例器
必须列出映射到XML模式元素的所有JavaBean属性
您需要为Customer
将CustomerFullAddress
属性添加到proporter
package org.abc.customers;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlRootElement(name = "customerfulladdress")
//If you want you can define the order in which the fields are written
//Optional
@XmlType(propOrder = { "address", "city", "region", "postalCode", "country" })
public class CustomerFullAddress {
private String address;
...
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
.....
}