javax.xml.bind problem in Java 11
How to solve the problem that javax.xml.bind package does not exist in Java 11?
According to the release documentation, Java 11 has removed Java EE modules:
Passed This problem can be solved by using an alternative version of Java EE technology. Just add the Maven dependencies containing the required classes:
<code class="xml"><dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-core</artifactId> <version>2.3.0</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> <version>2.3.0</version> </dependency></code>
Jakarta EE 8 Update (March 2020)
It is possible to use Jakarta EE 8 Jakarta XML Binding in instead of the old JAXB module:
<code class="xml"><dependency> <groupId>jakarta.xml.bind</groupId> <artifactId>jakarta.xml.bind-api</artifactId> <version>2.3.3</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> <version>2.3.3</version> <scope>runtime</scope> </dependency></code>
Jakarta EE 9 Update (November 2020)
Using Jakarta XML Binding 3.0 Latest version:
<code class="xml"><dependency> <groupId>jakarta.xml.bind</groupId> <artifactId>jakarta.xml.bind-api</artifactId> <version>3.0.0</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> <version>3.0.0</version> <scope>runtime</scope> </dependency></code>
Note: Jakarta EE 9 adopts the new API package namespace jakarta.xml.bind.*, so please update the import statement:
javax.xml.bind -> jakarta.xml.bind
Jakarta EE 10 Update (2022-6 Month)
Use the latest version of Jakarta XML Binding 4.0 (requires Java SE 11 or higher):
<code class="xml"><dependency> <groupId>jakarta.xml.bind</groupId> <artifactId>jakarta.xml.bind-api</artifactId> <version>4.0.0</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> <version>4.0.0</version> <scope>runtime</scope> </dependency></code>
The above is the detailed content of How to Resolve the `javax.xml.bind` Issue in Java 11?. For more information, please follow other related articles on the PHP Chinese website!