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