Tôi có một khách hàng và CustomerFullAddress lớp và tôi đang sử dụng JAXB để cố gắng tạo ra một tập tin XML2 đếm Chú trái phép ngoại lệ
<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>
The Class khách hàng trông giống như dưới đây (nó không phải là một thực hiện đầy đủ)
package org.abc.customers;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlRootElement(name = "customer")
@XmlType (propOrder = { "companyName", "contactName", "contactTitle", "phone" })
public class Customer {
*@XmlElement(name = "customerfulladdress")
private CustomerFullAddress custAdd;*
private String companyName;
private String contactName;
private String contactTitle;
private int phone;
public CustomerFullAddress getCustAddress() {
return custAdd;
}
public void setCustAddress(CustomerFullAddress custAdd) {
this.custAdd = custAdd;
}
...
trong khi CustomerFullAddress là
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;
}
.....
}
và lỗi là
Exception in thread "main" com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 tội danh IllegalAnnotationExceptions custAdd tài sản hiện diện nhưng không quy định tại @ XmlType.propOrder vấn đề này là liên quan đến vị trí sau: ở riêng org.abc.customers.CustomerFullAddress org.abc.customers.Customer.custAdd tại org.abc.customers.Customer custAddress tài sản được trình bày nhưng không quy định tại @ XmlType.propOrder này vấn đề có liên quan đến vị trí sau: tại công khai org.abc.customers.Cus tomerFullAddress org.abc.customers.Customer.getCustAddress() tại org.abc.customers.Customer
Cảm ơn vì đã xem!