我正在尝试从 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