2
我試圖從Play 2.0 Scala應用程序中使用JPA。在我的代碼有:無法從有效的persistence.xml創建EntityManager
val factory = Persistence.createEntityManagerFactory("devcrowd")
我也有persistence.xml
在包META-INF
:
<?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_2_0.xsd" version="2.0">
<persistence-unit name="devcrowd" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
<property name="hibernate.connection.username" value="xxxx"/>
<property name="hibernate.connection.password" value="xxxx"/>
<property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432/devcrowd"/>
</properties>
</persistence-unit>
</persistence>
這似乎的persistence.xml有效的給我,但工廠不能創建:
PersistenceException: No Persistence provider for EntityManager named devcrowd
減少堆棧跟蹤。檢查postgresql jdbc是否在classpath中。 – 2012-03-05 07:31:53
冬眠,就此而言。 – 2012-04-16 14:13:10