我的主要课程是
public static void main(String[] args) throws JAXBException,
FileNotFoundException {
Class[] classes = new Class[5];
classes[0] = com.kk.AddressDetails.class;
classes[1] = com.kk.COUNTRY.class;
classes[2] = com.kk.ObjectFactory.class;
classes[3] = com.kk.Details.class;
classes[4] = com.kk.Districts.class;
JAXBContext context = JAXBContext.newInstance(classes);
Unmarshaller unmarshaller = context.createUnmarshaller();
JAXBElement<COUNTRY> unmarshal = (JAXBElement<COUNTRY>) unmarshaller
.unmarshal(new File("src\\countrydetails.xml"));
COUNTRY value = unmarshal.getValue();
System.out.println(value);
因此,在编译这个时,我在线程“main”java.lang.ClassCastException 中得到了这个异常:com.kk.COUNTRY cannot be cast to javax.xml.bind.JAXBElement at main.kk.ClientApp.main(ClientApp.java:31)