Java jaxb解组器读取值为0

Java jaxb解组器读取值为0,java,jaxb,Java,Jaxb,如果XML文档与您的映射不匹配,则要解组的值将为null。最简单的方法是填充对象模型,然后将其编组以查看与当前映射对应的XML。如果所需名称与默认名称不同,则可以使用@XmlElement和@XmlAttribute指定要映射到的名称 如果同时映射字段及其相应的属性,您将看到以下异常。以下文章将帮助您: 将来,请格式化您的代码,并在将代码粘贴到编辑器中时使用代码{}按钮。在看不到XML和绑定类的情况下,除了猜测之外,我们没有什么可以做的;那是浪费我们和你的时间。 JAXBContext jaxb

如果XML文档与您的映射不匹配,则要解组的值将为null。最简单的方法是填充对象模型,然后将其编组以查看与当前映射对应的XML。如果所需名称与默认名称不同,则可以使用@XmlElement和@XmlAttribute指定要映射到的名称

如果同时映射字段及其相应的属性,您将看到以下异常。以下文章将帮助您:


将来,请格式化您的代码,并在将代码粘贴到编辑器中时使用代码{}按钮。在看不到XML和绑定类的情况下,除了猜测之外,我们没有什么可以做的;那是浪费我们和你的时间。
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());
}
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
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