模式切换
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlType
【问题】
原项目在 JDK 1.8 下正常运行,但在 JDK 11 下运行报错缺了某些 jar 包:
bash
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlType
【解决】
除了降低 JDK 版本的方法外,如果非要用 JDK 版本大于 1.8,则需在项目 pom 文件中添加相关依赖(根据实际需要添加):
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-impl</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>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>