Eclipse 中未解决的依赖项错误

Unresolved Dependency error in Eclipse

我在 eclipse 中针对简单的 Repository 界面不断收到以下错误。

The type org.springframework.data.repository.query.QueryByExampleExecutor
cannot be resolved.
It is indirectly referenced from required .class files

它是 MongoDB 的 Play Framework 2.5.1 项目。这是 build.sbt.

中的依赖项

libraryDependencies ++= Seq( javaCore, javaJpa, "javax.inject" % "javax.inject" % "1", "org.springframework" % "spring-core" % "4.3.3.RELEASE", "org.springframework" % "spring-context" % "4.3.3.RELEASE", "org.springframework" % "spring-beans" % "4.3.4.RELEASE" "org.springframework" % "spring-jdbc" % "4.3.4.RELEASE", "org.springframework.data" % "spring-data-jpa" % "1.10.1.RELEASE", "org.springframework.data" % "spring-data-commons-core" % "1.4.1.RELEASE", "org.springframework" % "spring-expression" % "4.3.3.RELEASE", "org.mongodb" % "mongo-java-driver" % "3.2.2", "org.springframework.data" % "spring-data-mongodb" % "1.9.2.RELEASE", "org.mockito" % "mockito-core" % "1.9.5" % "test" )

谁能帮我解决这个问题

问题出在 spring-data-jpa 1.10.1 发布版本引用的 spring 数据公共依赖项。

https://github.com/spring-projects/spring-data-jpa/blob/1.10.1.Release/pom.xml

pom.xml 依赖于 1.12.1.RELEASE 并且事实上 QueryByExampleExecutor javadocs建议这个 class 是在 1.12 版本中添加的。

您引用的 spring 数据共享版本是旧的 1.4。1.Release。所以现在的解决方法是将 spring 数据版本升级到 1.12.1。另一个修复可能是将 spring-data-jpa 降级到使用 spring data commons 1.4.1.Release version.

的版本

顺便说一句,您应该考虑使用像 Maven 这样的依赖管理工具来避免将来出现此类问题。