1
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ゲッター/セッターにも注釈が付けられますが、例外がスローされます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
4

1 に答える 1