ScalaTest 和 Mockito - 未解决的依赖关系
ScalaTest and Mockito - unresolved dependency
我正在尝试在 SBT 构建文件中添加 mockito 依赖项,但它给出了以下未解决的依赖项异常。
我不确定是不是 Scala 和 Mockito 版本的问题。
scalaVersion := "2.11.8"
libraryDependencies ++= Seq("org.scalatest" % "scalatest_2.11" % "2.2.2" % "test",
"org.mockito" % "mockito-all" % "1.9.5" % "test")
异常:
trace] Stack trace suppressed: run 'last *:ssExtractDependencies' for the full output.
[trace] Stack trace suppressed: run 'last *:update' for the full output.
[error] (*:ssExtractDependencies) sbt.ResolveException: unresolved dependency: org.mockito#mockito-all;1.9.5: not found
[error] (*:update) sbt.ResolveException: unresolved dependency: org.mockito#mockito-all;1.9.5: not found
[error] Total time: 23 s, completed Oct 12, 2017 3:13:16 PM
我也尝试过使用不同的 mockito 版本 1.8.5。但是运气不好。
提前致谢。
我强烈建议不要将 mockito-all 与 sbt 一起使用,而是使用 mockito-core。 SBT 是智能构建系统,它会找出 mockito-core 的所有依赖项,details。您的依赖项可能如下所示:
libraryDependencies ++= Seq (
"org.scalatest" %% "scalatest" % "3.0.1" % "test",
"org.mockito" % "mockito-core" % "2.8.47" % "test"
)
Mockito documentation advises to not use mockito-core as a dependency, but to use mockito-scala which will pull what's needed. You could use the %% notation which automatically pulls the version appropriate for the Scala version you are using. It's also worth looking on Maven 查看哪个是您正在使用的 Scala 版本的最新 mockito-scala 版本。
所以 Mockito 的 build.sbt 与今天最新版本的 Scala 一起使用是:
libraryDependencies ++= Seq (
"org.mockito" %% "mockito-scala" % "1.15.0" % "test"
)
我正在尝试在 SBT 构建文件中添加 mockito 依赖项,但它给出了以下未解决的依赖项异常。
我不确定是不是 Scala 和 Mockito 版本的问题。
scalaVersion := "2.11.8"
libraryDependencies ++= Seq("org.scalatest" % "scalatest_2.11" % "2.2.2" % "test",
"org.mockito" % "mockito-all" % "1.9.5" % "test")
异常:
trace] Stack trace suppressed: run 'last *:ssExtractDependencies' for the full output.
[trace] Stack trace suppressed: run 'last *:update' for the full output.
[error] (*:ssExtractDependencies) sbt.ResolveException: unresolved dependency: org.mockito#mockito-all;1.9.5: not found
[error] (*:update) sbt.ResolveException: unresolved dependency: org.mockito#mockito-all;1.9.5: not found
[error] Total time: 23 s, completed Oct 12, 2017 3:13:16 PM
我也尝试过使用不同的 mockito 版本 1.8.5。但是运气不好。
提前致谢。
我强烈建议不要将 mockito-all 与 sbt 一起使用,而是使用 mockito-core。 SBT 是智能构建系统,它会找出 mockito-core 的所有依赖项,details。您的依赖项可能如下所示:
libraryDependencies ++= Seq (
"org.scalatest" %% "scalatest" % "3.0.1" % "test",
"org.mockito" % "mockito-core" % "2.8.47" % "test"
)
Mockito documentation advises to not use mockito-core as a dependency, but to use mockito-scala which will pull what's needed. You could use the %% notation which automatically pulls the version appropriate for the Scala version you are using. It's also worth looking on Maven 查看哪个是您正在使用的 Scala 版本的最新 mockito-scala 版本。
所以 Mockito 的 build.sbt 与今天最新版本的 Scala 一起使用是:
libraryDependencies ++= Seq (
"org.mockito" %% "mockito-scala" % "1.15.0" % "test"
)