使用Hibernate JPA和Postgres来玩2.2 [英] Play 2.2 with Hibernate JPA and Postgres
问题描述
我试图让一个Play 2.2项目与Hibernate JPA和一个PostgreSQL数据库一起工作。我之前使用Play 2.1.1完成了它的工作。我现在得到以下错误:
pre $ play.api.UnexpectedException:意外的异常[NoClassDefFoundError:org / w3c / dom / ElementTraversal]
at play.core.ReloadableApplication $$ anonfun $ get $ 1 $$ anonfun $ apply $ 1 $$ anonfun $ 1.apply(ApplicationProvider.scala:152)〜[play_2.10.jar:2.2.0]
我不知道这是从哪里来的。我的build.sbt看起来像这样:
$ b
libraryDependencies ++ = Seq(
javaJdbc ,
缓存,
javaJpa,
org.apache.directory.api%apache-ldap-api%1.0.0-M14,
postgresql %postgresql%9.1-901-1.jdbc4,
org.hibernate%hibernate-core%4.2.3.Final,
org.hibernate% hibernate-entitymanager%4.2.3.Final
)
和我的持久性。 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>
<非-jta-data-source> DefaultDS< /非-jta-data-source>
<属性>
< property name =hibernate.dialectvalue =org.hibernate.dialect.PostgreSQLDialect/>
< property name =hibernate.hbm2ddl.autovalue =update/>
< / properties>
< / persistence-unit>
我还没有写过代码,但我只是配置它。
好的,我自己想清楚了。这确实是两个版本的xml-apis的问题。一个来自Play本身,另一个来自Apache Directory API。我改变了build.sbt中的artefact并且它现在正在工作:
org.apache.directory.api% api-all%1.0.0-M14
I'm trying to get a Play 2.2 project to work with Hibernate JPA and a PostgreSQL database. I did it before with Play 2.1.1, where it worked perfectly. I get the following error now:
play.api.UnexpectedException: Unexpected exception[NoClassDefFoundError: org/w3c/dom/ElementTraversal]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:152) ~[play_2.10.jar:2.2.0]
I have no idea where this comes from. My build.sbt looks like this:
libraryDependencies ++= Seq(
javaJdbc,
cache,
javaJpa,
"org.apache.directory.api" % "apache-ldap-api" % "1.0.0-M14",
"postgresql" % "postgresql" % "9.1-901-1.jdbc4",
"org.hibernate" % "hibernate-core" % "4.2.3.Final",
"org.hibernate" % "hibernate-entitymanager" % "4.2.3.Final"
)
And my persistence.xml like this:
<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.PostgreSQLDialect" />
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
I haven't written any code yet, I just configured it.
Ok, figured it out by myself. It was indeed a problem with two versions of xml-apis. One coming from Play itself and one from the Apache Directory API. I changed the artefact in the build.sbt to and it is working now:
"org.apache.directory.api" % "api-all" % "1.0.0-M14"
这篇关于使用Hibernate JPA和Postgres来玩2.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!