問題:
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]