sbt->compile 后未找到 org.scalacheck 和 org.scalatest

Posted

技术标签:

【中文标题】sbt->compile 后未找到 org.scalacheck 和 org.scalatest【英文标题】:org.scalacheck and org.scalatest not found after sbt->compile 【发布时间】:2017-08-25 04:17:30 【问题描述】:
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: org.scalatest#scalatest_2.12;2.2.4: not found
[error] unresolved dependency: org.scalacheck#scalacheck_2.12;1.12.1: not found
[error] unresolved dependency: org.scalactic#scalatest;3.0.1: not found
[error] unresolved dependency: org.scalacheck#scalacheck;1.13.4: not found
[error] unresolved dependency: org.scalatest#scalatest;3.0.1: not found

在 scala-2.12.1/lib/ 中存在以下文件: scalacheck_2.12-1.13.4.jar scalactic_2.11-3.0.1.jar scalatest_2.11-3.0.1.jar

在 build.sbt 中包含:

scalaVersion := "2.12.1"
libraryDependencies += "junit" % "junit" % "4.10" % "test"
libraryDependencies ++= assignmentsMap.value.values.flatMap(_.dependencies).toSeq
libraryDependencies += "org.scalacheck" % "scalacheck" % "1.13.4" % "test"
libraryDependencies += "org.scalactic" % "scalatest" % "3.0.1"
libraryDependencies += "org.scalatest" % "scalatest" % "3.0.1" % "test"

但是$ sbt然后编译错误被抛出: scala> developer@cn-vm-yourname:~/example/quickcheck$ sbt [info] 从 /home/developer/.sbt/0.13/plugins 加载全局插件 [信息] 从 /home/developer/example/quickcheck/project 加载项目定义 [info] 将当前项目设置为 progfun2-quickcheck(在构建文件中:/home/developer/example/quickcheck/)

编译

[info] Updating file:/home/developer/example/quickcheck/root...
[info] Resolving org.scalatest#scalatest_2.12;2.2.4 ...
[warn]  module not found: org.scalatest#scalatest_2.12;2.2.4
[warn] ==== local: tried
[warn]   /home/developer/.ivy2/local/org.scalatest/scalatest_2.12/2.2.4/ivys/ivy.xml
[warn] ==== activator-launcher-local: tried
[warn]   /home/developer/.activator/repository/org.scalatest/scalatest_2.12/2.2.4/ivys/ivy.xml
[warn] ==== activator-local: tried
[warn]   /home/developer/activator-dist-1.3.12/repository/org.scalatest/scalatest_2.12/2.2.4/ivys/ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/org/scalatest/scalatest_2.12/2.2.4/scalatest_2.12-2.2.4.pom
[warn] ==== typesafe-releases: tried
[warn]   http://repo.typesafe.com/typesafe/releases/org/scalatest/scalatest_2.12/2.2.4/scalatest_2.12-2.2.4.pom
[warn] ==== typesafe-ivy-releasez: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/org.scalatest/scalatest_2.12/2.2.4/ivys/ivy.xml
[info] Resolving org.scalacheck#scalacheck_2.12;1.12.1 ...
[warn]  module not found: org.scalacheck#scalacheck_2.12;1.12.1
[warn] ==== local: tried
[warn]   /home/developer/.ivy2/local/org.scalacheck/scalacheck_2.12/1.12.1/ivys/ivy.xml
[warn] ==== activator-launcher-local: tried
[warn]   /home/developer/.activator/repository/org.scalacheck/scalacheck_2.12/1.12.1/ivys/ivy.xml
[warn] ==== activator-local: tried
[warn]   /home/developer/activator-dist-1.3.12/repository/org.scalacheck/scalacheck_2.12/1.12.1/ivys/ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/org/scalacheck/scalacheck_2.12/1.12.1/scalacheck_2.12-1.12.1.pom
[warn] ==== typesafe-releases: tried
[warn]   http://repo.typesafe.com/typesafe/releases/org/scalacheck/scalacheck_2.12/1.12.1/scalacheck_2.12-1.12.1.pom
[warn] ==== typesafe-ivy-releasez: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/org.scalacheck/scalacheck_2.12/1.12.1/ivys/ivy.xml
[info] Resolving org.scalactic#scalatest;3.0.1 ...
[warn]  module not found: org.scalactic#scalatest;3.0.1
[warn] ==== local: tried
[warn]   /home/developer/.ivy2/local/org.scalactic/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== activator-launcher-local: tried
[warn]   /home/developer/.activator/repository/org.scalactic/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== activator-local: tried
[warn]   /home/developer/activator-dist-1.3.12/repository/org.scalactic/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/org/scalactic/scalatest/3.0.1/scalatest-3.0.1.pom
[warn] ==== typesafe-releases: tried
[warn]   http://repo.typesafe.com/typesafe/releases/org/scalactic/scalatest/3.0.1/scalatest-3.0.1.pom
[warn] ==== typesafe-ivy-releasez: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/org.scalactic/scalatest/3.0.1/ivys/ivy.xml
[info] Resolving org.scalacheck#scalacheck;1.13.4 ...
[warn]  module not found: org.scalacheck#scalacheck;1.13.4
[warn] ==== local: tried
[warn]   /home/developer/.ivy2/local/org.scalacheck/scalacheck/1.13.4/ivys/ivy.xml
[warn] ==== activator-launcher-local: tried
[warn]   /home/developer/.activator/repository/org.scalacheck/scalacheck/1.13.4/ivys/ivy.xml
[warn] ==== activator-local: tried
[warn]   /home/developer/activator-dist-1.3.12/repository/org.scalacheck/scalacheck/1.13.4/ivys/ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/org/scalacheck/scalacheck/1.13.4/scalacheck-1.13.4.pom
[warn] ==== typesafe-releases: tried
[warn]   http://repo.typesafe.com/typesafe/releases/org/scalacheck/scalacheck/1.13.4/scalacheck-1.13.4.pom
[warn] ==== typesafe-ivy-releasez: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/org.scalacheck/scalacheck/1.13.4/ivys/ivy.xml
[info] Resolving org.scalatest#scalatest;3.0.1 ...
[warn]  module not found: org.scalatest#scalatest;3.0.1
[warn] ==== local: tried
[warn]   /home/developer/.ivy2/local/org.scalatest/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== activator-launcher-local: tried
[warn]   /home/developer/.activator/repository/org.scalatest/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== activator-local: tried
[warn]   /home/developer/activator-dist-1.3.12/repository/org.scalatest/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/org/scalatest/scalatest/3.0.1/scalatest-3.0.1.pom
[warn] ==== typesafe-releases: tried
[warn]   http://repo.typesafe.com/typesafe/releases/org/scalatest/scalatest/3.0.1/scalatest-3.0.1.pom
[warn] ==== typesafe-ivy-releasez: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/org.scalatest/scalatest/3.0.1/ivys/ivy.xml
[info] Resolving jline#jline;2.14.1 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: org.scalatest#scalatest_2.12;2.2.4: not found
[warn]  :: org.scalacheck#scalacheck_2.12;1.12.1: not found
[warn]  :: org.scalactic#scalatest;3.0.1: not found
[warn]  :: org.scalacheck#scalacheck;1.13.4: not found
[warn]  :: org.scalatest#scalatest;3.0.1: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn] 
[warn]  Note: Unresolved dependencies path:
[warn]      org.scalatest:scalatest_2.12:2.2.4 (/home/developer/example/quickcheck/project/StudentBuildLike.scala#L27)
[warn]        +- progfun2-quickcheck:progfun2-quickcheck_2.12:0.1-SNAPSHOT
[warn]      org.scalactic:scalatest:3.0.1 (/home/developer/example/quickcheck/build.sbt#L11-12)
[warn]        +- progfun2-quickcheck:progfun2-quickcheck_2.12:0.1-SNAPSHOT
[warn]      org.scalacheck:scalacheck:1.13.4 (/home/developer/example/quickcheck/build.sbt#L10-11)
[warn]        +- progfun2-quickcheck:progfun2-quickcheck_2.12:0.1-SNAPSHOT
[warn]      org.scalatest:scalatest:3.0.1 (/home/developer/example/quickcheck/build.sbt#L12-13)
[warn]        +- progfun2-quickcheck:progfun2-quickcheck_2.12:0.1-SNAPSHOT
[warn]      org.scalacheck:scalacheck_2.12:1.12.1 (/home/developer/example/quickcheck/build.sbt#L9-10)
[warn]        +- progfun2-quickcheck:progfun2-quickcheck_2.12:0.1-SNAPSHOT
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: org.scalatest#scalatest_2.12;2.2.4: not found
[error] unresolved dependency: org.scalacheck#scalacheck_2.12;1.12.1: not found
[error] unresolved dependency: org.scalactic#scalatest;3.0.1: not found
[error] unresolved dependency: org.scalacheck#scalacheck;1.13.4: not found
[error] unresolved dependency: org.scalatest#scalatest;3.0.1: not found

【问题讨论】:

我们不知道assignmentsMap.value.values.flatMap(_.dependencies).toSeq 包含什么。 奇怪的是,您在 testcompile 中都使用 scalatest 进行编译。 【参考方案1】:

尝试从 build.sbt 中删除这一行:

libraryDependencies += "org.scalactic" % "scalatest" % "3.0.1"

【讨论】:

scalacheck 的问题未解决,scalatest 依赖项 重新安装 scala、sbt 和作业后问题解决【参考方案2】:

在 plugins.sbt 文件中确保 sbt-plugin 版本大于或等于 2.3.8

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.8")

【讨论】:

以上是关于sbt->compile 后未找到 org.scalacheck 和 org.scalatest的主要内容,如果未能解决你的问题,请参考以下文章

未找到模块:org.scala-sbt#sbt;1.1.6

未找到:https://repo1.maven.org/maven2/org/jetbrains/sbt-idea-shell_2.12_1.0/2017.2/sbt-idea-shell-2017.

SBT 在 Sources 中查找子类型

sbt - 服务器访问错误:连接重置?

IntelliJ Idea 找不到 sbt-idea-compiler-indices

Error:scalac: Error: Error compiling the sbt component ‘compiler-interface-2.11.8-55.0‘