spring 嵌套异常为java. lang. NoClassDefFoundError:雅加达/持久性/spi/持久性提供程序

2cmtqfgy  于 2023-02-28  发布在  Spring
关注(0)|答案(1)|浏览(395)

java.lang.ClassNotFoundException:在将org. hib:hibernate-core从版本5.6.14.Final升级到6.2.0.CR2时提供持久性。我在java11上运行应用程序

nc1teljy

nc1teljy1#

The java.lang.ClassNotFoundException: jakarta.persistence.spi.PersistenceProvider error occurs because the jakarta.persistence.spi.PersistenceProvider class is not found on the classpath at runtime.
In Hibernate 6, there have been some changes to the way JPA APIs are packaged and organized, which may cause issues when upgrading from previous versions. One possible cause of this issue is that you are missing a required dependency for the jakarta.persistence.spi.PersistenceProvider class.
To resolve this issue, you can try adding the following dependency to your project's build file (e.g. pom.xml for Maven or build.gradle for Gradle):
For Maven :

<dependency>
    <groupId>jakarta.persistence</groupId>
    <artifactId>jakarta.persistence-api</artifactId>
    <version>3.0.0</version>
</dependency>

For Gradle :

implementation 'jakarta.persistence:jakarta.persistence-api:3.0.0'

This should provide the necessary JPA API classes and resolve the ClassNotFoundException.
If this doesn't resolve the issue, you may also need to check if any other dependencies are conflicting with the Hibernate 6 version you are using.
I hope this helps!

相关问题