最佳答案
我试图使用JAXB将XML数据反序列化到Java内容树中,在XML数据被解组时验证它:
try {
JAXBContext context = JAXBContext.newInstance("com.acme.foo");
Unmarshaller unmarshaller = context.createUnmarshaller();
unmarshaller.setSchema(schema);
FooObject fooObj = (FooObject) unmarshaller.unmarshal(new File("foo.xml"));
} catch (UnmarshalException ex) {
ex.printStackTrace();
} catch (JAXBException ex) {
ex.printStackTrace();
}
当我用Java 8构建项目时,它很好,但用Java 11构建它失败,并出现编译错误:
package javax.xml.bind does not exist
我如何解决这个问题?