1 回答
TA贡献1883条经验 获得超3个赞
嵌套异常是java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlElement
简而言之:随着 Java 9 的发布,所需的依赖项已从 JDK 中删除。如果您使用 Java 8 JDK 启动应用程序,则会提供依赖项并且您的应用程序可以正常运行。如果您使用 Java 9 JDK 或更高版本启动应用程序,则依赖项将不再存在并且无法启动。
修复此问题的正确解决方案是将所需的依赖项添加到您的项目中:
dependencies {
// JAX-B dependencies for JDK 9+
implementation "javax.xml.bind:jaxb-api:2.2.11"
implementation "com.sun.xml.bind:jaxb-core:2.2.11"
implementation "com.sun.xml.bind:jaxb-impl:2.2.11"
implementation "javax.activation:activation:1.1.1"
}
Maven 依赖项
<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.11</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-core -->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.11</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-impl -->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.activation/activation -->
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
添加回答
举报