且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

javax.persistence.Table.indexes()中的NoSuchMethodError [Ljavax / persistence / Index

更新时间:2023-09-20 22:30:04

我遇到了同样的问题。这里的问题是play-java-jpa artifact(build.sbt文件中的javaJpa键)依赖于spec (版本2.0 - >org.hibernate.javax.persistence %hibernate-jpa-2.0-api%1.0.1.Final)

I've ran into the same problem. The question here is that play-java-jpa artifact (javaJpa key in the build.sbt file) depends on a different version of the spec (version 2.0 -> "org.hibernate.javax.persistence" % "hibernate-jpa-2.0-api" % "1.0.1.Final").

当你添加hibernate-entitymanager 4.3这个为实体管理者带来了更新的规范(2.1)和不同的工厂提供者。基本上你最终将classpath中的两个jar作为传递依赖。

When you added hibernate-entitymanager 4.3 this brought the newer spec (2.1) and a different factory provider for the entitymanager. Basically you ended up having both jars in the classpath as transitive dependencies.

编辑你的build.sbt文件,它会暂时解决你的问题,直到play发布一个新版本

Edit your build.sbt file like this and it will temporarily fix you problem until play releases a new version of the jpa plugin for the newer api dependency.

libraryDependencies ++= Seq(
javaJdbc,
javaJpa.exclude("org.hibernate.javax.persistence", "hibernate-jpa-2.0-api"),
"org.hibernate" % "hibernate-entitymanager" % "4.3.0.Final"
)

这是用于 play 2.2.x 。在以前的版本中,构建文件存在一些差异。

This is for play 2.2.x. In previous versions there were some differences in the build files.