我试图在我的Play应用程序中使用JPA,并且当我尝试加载我的应用程序时,我收到一个PersistenceException:没有名为EntityPersistenceUnit的EntityManager的持久性提供程序
这些是我的设置:build.sbt
libraryDependencies ++= Seq(
....
"mysql" % "mysql-connector-java" % "5.1.28",
javaJpa,
"org.hibernate" % "hibernate-entitymanager" % "3.6.9.Final"
)
conf / META-INF / persistence.xml
<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="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>DefaultDS</non-jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
</properties>
</persistence-unit>
</persistence>
application.conf
db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://localhost/testDB"
db.default.user="root"
db.default.password="root"
db.default.jndiName=DefaultDS
jpa.default=defaultPersistenceUnit
能否请别人告诉我我在做什么错...谢谢。
当您的上述信息正确无误时,我认为是文件名错字:重命名conf/META-INF/persistance.xml
为conf/META-INF/persistence.xml
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句