# Java 项目编译的时候提示 javax.xml.bind.annotation does not exist 错误

**URL:** <https://www.isharkfly.com/t/java-javax-xml-bind-annotation-does-not-exist/13958>\
**Category:** 程序语言\
**Tags:** java\
**Created:** [May 8, 2022, 8:02pm UTC](https://www.isharkfly.com/t/java-javax-xml-bind-annotation-does-not-exist/13958 "2022-05-08T20:02:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![honeymoose](https://www.isharkfly.com/user_avatar/www.isharkfly.com/honeymoose/32/20796_2.png) [@honeymoose](https://www.isharkfly.com/u/honeymoose)\
**Post date:** [May 8, 2022, 8:02pm UTC](https://www.isharkfly.com/t/java-javax-xml-bind-annotation-does-not-exist/13958/1 "2022-05-08T20:02:00Z")

</div>

提示的错误信息为：

`javax.xml.bind.annotation does not exist`

![javax-01](https://www.isharkfly.com/images/transparent.png)

## 错误原因

这是因为针对这个老的项目，我们是使用 JDK 11 进行编译的。

但是 JDK 11 中已经没有： `javax.xml.bind` 这个包。

需要在 POM 的依赖中添加下面的内容：

```auto
		<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>

```

 ![javax-02](https://com-ossez-www-discourse.s3.dualstack.us-east-2.amazonaws.com/discourse-uploads/original/2X/8/81b9fc79098a77122dd63d2d8d6b0864b3babcf0.png)

添加上面的依赖到 POM 文件中就可以解决编译的错误了。
