我有一个No Persistence provider for EntityManager
异常,无法弄清楚是什么原因造成的。这是我的配置文件:
Persistence.xml(存储在src/META-INF
)
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
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_2_0.xsd">
<persistence-unit name="HatifimJPA" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>entities.HatUser</class>
<properties>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" />
<property name="hibernate.connection.username" value="Benny" />
<property name="hibernate.connection.password" value="oracle" />
<property name="hibernate.connection.url" value="jdbc:oracle:thin:@localhost:1521:xe" />
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect" />
</properties>
</persistence-unit>
</persistence>
例外:
线程“主”javax.persistence.PersistenceException 中的异常:在 javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:69) 在 javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) 中没有名为 HatifimJPA 的 EntityManager 的持久性提供程序testing.TestClass.main(TestClass.java:16)
唯一的区别是我试图EntityManager
进入一个public void main(...) { ... }
街区,但是,我不记得过去这样做有问题。
谁能帮忙指出我的问题可能出在哪里?