问题:
I'm trying to deserialize XML data into a Java content tree using JAXB , validating the XML data as it is unmarshalled:我正在尝试使用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();
}
When I build the project with Java 8 it's fine, but building it with Java 11 fails with a compilation error:当我使用Java 8构建项目时它很好,但是使用Java 11构建它失败并出现编译错误:
package javax.xml.bind does not exist
How do I fix the issue?我该如何解决这个问题?
解决方案:
参考一: https://stackoom.com/question/3YIDV参考二: Java 11 package javax.xml.bind does not exist [duplicate]