JAXBContext jaxbContext = JAXBContext.newInstance(BatchwisePricingJob.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
StringReader reader = new StringReader(batchprice.toString());
BatchwisePricingJob batch = (BatchwisePricingJob) jaxbUnmarshaller.unmarshal(reader);
ArrayList<Price> pricingOfProduct = batch.getPricingOfProduct();
int i = 0;
for (Price price : pricingOfProduct) {
i++;
System.out.println("customer id:" + i + " " + price.getCustomerId());
System.out.println("material id:" + i + " " + price.getMaterialId());
}
还@XmlElement
为 getter/setter 提供了注释,但随后它引发了异常Illegealannotationexception
Class has two properties of the same name "customerId"
this problem is related to the following location:
at public int com.efl.efms.batch.ws.data.batchwisePricing.Price.getCustomerId()
at com.efl.efms.batch.ws.data.batchwisePricing.Price
at private java.util.ArrayList com.efl.efms.batch.ws.data.batchwisePricing.BatchwisePricingJob.pricingOfProduct
at com.efl.efms.batch.ws.data.batchwisePricing.BatchwisePricingJob
this problem is related to the following location:
at private int com.efl.efms.batch.ws.data.batchwisePricing.Price.customerId
at com.efl.efms.batch.ws.data.batchwisePricing.Price
at private java.util.ArrayList com.efl.efms.batch.ws.data.batchwisePricing.BatchwisePricingJob.pricingOfProduct
at com.efl.efms.batch.ws.data.batchwisePricing.BatchwisePricingJob