无法从有效的persistence.xml创建EntityManager

时间:2012-03-04 16:53:27

标签: scala jpa playframework-2.0

我正在尝试使用Play 2.0 Scala应用程序中的JPA。在我的代码中,我有:

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

1 个答案:

答案 0 :(得分:1)

您在部署时缺少Hibernate库。