Java 11 包 javax.xml.bind 不存在 [重复] - Java 11 package javax.xml.bind does not exist [duplicate]

问题:

This question already has answers here : 这个问题在这里已经有了答案
Closed 2 years ago . 2年前关闭。

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]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章