我正在尝试使用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();
}
Run Code Online (Sandbox Code Playgroud)
当我使用Java 8构建项目时,它很好,但使用Java 11构建它失败并出现编译错误:
package javax.xml.bind does not exist
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?