Hello I need help to solve this problem. When trying to run my java web application on intellij i get the following message:
javax.persistence.PersistenceException: No Persistence provider for EntityManager named persistence
-- src
|-- main
| |-- java
| | `-- service
| | `-- dao
| | `-- mapping
| | |--
| | |--
| | `--
| `-- resources
| `-- META-INF
| `-- persistence.xml
here is my persistence.xml
file in resources/META-INF/
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0">
<persistence-unit name="persistence">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<mapping-file>Dao/mapping/user.xml</mapping-file>
<class>Dao.mapping.UserEntity</class>
<properties>
<property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/test"/>
<property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/test"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost:3306/test"/>
<property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver"/>
<property name="eclipselink.jdbc.url" value="jdbc:mysql://localhost:3306/test"/>
<property name="eclipselink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
</properties>
</persistence-unit>
my gradle build
group 'com.test'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'war'
sourceCompatibility = 1.5
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
compile group: 'org.hibernate', name: 'hibernate-core', version: '5.2.4.Final'
compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.5'
compile group: 'org.apache.tomcat', name: 'tomcat-catalina', version: '9.0.0.M13'
compile group: 'org.hibernate', name: 'hibernate-validator', version: '5.3.3.Final'
compile group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.1-api', version: '1.0.0.Final-redhat-1'
}
thank you .
One option is that the error is caused by the referenced entity not existing.
You have "Dao.mapping.UserEntity" in the persistence.xml, but the directory suggests it should be "service.dao.mapping.UserEntity".
A complete stacktrace could help solve the problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.