【发布时间】:2015-11-08 16:35:12
【问题描述】:
您好,我是 Java Web 的新手,我遇到了一个问题,我得到了这个沟通 javax.persistence.PersistenceException:没有名为 NaszSerwisPU 的 EntityManager 的持久性提供程序
这是我的 persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemalocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
<persistence-unit name="NaszSerwisPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>User</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.password" value="passsword"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/naszserwis"/>
<property name="hibernate.max_fetch_depth" value="3"/>
</properties>
</persistence-unit>
</persistence>
我试着打电话:
public String logIn() {
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("NaszSerwisPU");
EntityManager mgr = entityManagerFactory.createEntityManager();
User us = new User();
us.setLogin("admin");
us.setPassword("admin");
mgr.persist(us);
return "/main.xhtml";
}
我不知道我为什么会这样交流。 我使用 NetBeans
更新: 我已经删除了 hibernate.cfg.xml 并进行了更改
<provider>org.hibernate.ejb.HibernatePersistenceProvider></provider>
到:
<provider>org.hibernate.jpa.HibernatePersistenceProvider></provider>
但问题依然存在,错误的沟通是一样的。
【问题讨论】: