Home > Java > javaTutorial > How to Resolve the `javax.xml.bind` Issue in Java 11?

How to Resolve the `javax.xml.bind` Issue in Java 11?

Susan Sarandon
Release: 2024-11-06 00:20:02
Original
779 people have browsed it

How to Resolve the `javax.xml.bind` Issue in Java 11?

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:

  • java.xml.bind (JAXB) - Removed

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>
Copy after login

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>
Copy after login

Jakarta EE 9 Update (November 2020)

Using Jakarta XML Binding 3.0 Latest version:

  • Jakarta EE 9 API jakarta.xml.bind-api
  • compatible implementation jaxb-impl
<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>
Copy after login

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
Copy after login

Jakarta EE 10 Update (2022-6 Month)

Use the latest version of Jakarta XML Binding 4.0 (requires Java SE 11 or higher):

  • Jakarta EE 10 API jakarta.xml.bind-api
  • Compatible implementation of jaxb-impl
<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>
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template