我在build.gradle中有hibernate依赖项,但是我得到了以下错误
> Task :JPABootstrapping.main() FAILED
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named recipes
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:61)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
at setup.JPABootstrapping.main(JPABootstrapping.java:10)
Execution failed for task ':JPABootstrapping.main()'.
> Process 'command '/usr/lib/jvm/java-14-openjdk-amd64/bin/java'' finished with non-zero exit value 1
这个 persistence.xml
在下面 src/main/resources/META-INF
```
Hibernate Tips
org.hibernate.jpa.HibernatePersistenceProvider
false
intellij的检测功能显示 `HibernatePersistenceProvider` 无法解析:
![](https://i.stack.imgur.com/0EPN3.png)
这个 `build.gradle` 包含hibernate核心和postgresql驱动程序依赖项:
plugins {
id 'java'
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
implementation group: 'org.hibernate', name: 'hibernate-core', version: '5.0.5.Final'
implementation group: 'org.postgresql', name: 'postgresql', version: '42.2.18'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
1条答案
按热度按时间ou6hu8tu1#
那个
hibernate-core
确实很古老,更确切地说是在2015年发布的。那件文物里没有org.hibernate.jpa.HibernatePersistenceProvider
班级。从那以后,hibernate被重命名和重构了很多。最新稳定是:implementation group: 'org.hibernate', name: 'hibernate-core', version: '5.4.26.Final'
这个神器有这个等级。附加信息:hibernate将被重新命名。新坐标将:
implementation group: 'org.hibernate.orm', name: 'hibernate-core', version: '6.0.0.Final'
.