[英]How to solve " Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException"
How to solve " Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException" When I run the same code with Java 15, at runtime I get errors indicating that如何解决“ Exception in thread “main” java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException” 当我用 Java 15 运行相同的代码时,在运行时我收到错误提示
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
at org.hibernate.boot.spi.XmlMappingBinderAccess.<init>(XmlMappingBinderAccess.java:43)
at org.hibernate.boot.MetadataSources.<init>(MetadataSources.java:87)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:123)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:118)
at com.hibernatedemo.Main.main(Main.java:13)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more
I added the pom.xml but it didn't work我添加了 pom.xml 但它没有用
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
The version 2.3.1 of jaxb-api is not compatible with Java 15. Try this: jaxb-api 的版本 2.3.1 与 Java 不兼容 15. 试试这个:
<dependencies>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.3</version>
</dependency>
</dependencies>
If you are still experiencing issues after adding these dependencies, try cleaning and rebuilding the project to ensure that all dependencies are correctly resolved and included in the classpath.如果您在添加这些依赖项后仍然遇到问题,请尝试清理并重建项目以确保所有依赖项都已正确解析并包含在类路径中。
I downloaded and built the "jaxb-api-2.3.0.jar" file separately and my problem was solved.我单独下载并构建了“jaxb-api-2.3.0.jar”文件,我的问题就解决了。 Thank you very much, there is nothing related to "pom.xml"
非常感谢,没有与“pom.xml”相关的内容
If anyone else encounters this problem, they can download the file from here.如果其他人遇到此问题,他们可以从此处下载文件。 jaxb-api-2.3.0.jar
jaxb-api-2.3.0.jar
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.