加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

sbt – 如何将库依赖项更新为Scala版本?

发布时间:2020-12-14 04:59:10 所属栏目:百科 来源:网络整理
导读:我正在用sbt编译我的项目,并且得到了一个无法解决的依赖项错误. 事实是我从在线博客中获取了我使用的示例(一个hello world程序),它使用scalaVersion:=“2.10.0”,如下所示.我使用的是2.11.2. 如何将库依赖项(在build.sbt中)更新到最新版本的Scala,特别是修
我正在用sbt编译我的项目,并且得到了一个无法解决的依赖项错误.

事实是我从在线博客中获取了我使用的示例(一个hello world程序),它使用scalaVersion:=“2.10.0”,如下所示.我使用的是2.11.2.

如何将库依赖项(在build.sbt中)更新到最新版本的Scala,特别是修订版部分?

build.sbt

name := "Hello Test #1"

version := "1.0"

scalaVersion := "2.10.0"

resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"

libraryDependencies += "com.typesafe.akka" % "akka-actor_2.10" % "2.2-M1"

错误:

[info] Resolving com.typesafe.akka#akka-actor_2.11.2;2.2-M1 ...
[warn]  module not found: com.typesafe.akka#akka-actor_2.11.2;2.2-M1
[warn] ==== local: tried
[warn]   /home/plard/.ivy2/local/com.typesafe.akka/akka-actor_2.11.2/2.2-M1/ivys/ivy.xml
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/com/typesafe/akka/akka-actor_2.11.2/2.2-M1/akka-actor_2.11.2-2.2-M1.pom
[warn] ==== Typesafe Repository: tried
[warn]   http://repo.typesafe.com/typesafe/releases/com/typesafe/akka/akka-actor_2.11.2/2.2-M1/akka-actor_2.11.2-2.2-M1.pom
[info] Resolving jline#jline;2.12 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.typesafe.akka#akka-actor_2.11.2;2.2-M1: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.akka#akka-actor_2.11.2;2.2-M1: not found
[error] Total time: 1 s,completed Aug 11,2014 10:32:11 AM

解决方法

name := "Hello Test #1"

version := "1.0"

scalaVersion := "2.11.2"

resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"

libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.3.4"

这应该做到这一点.请注意%%和没有为Akka工件指定的版本.这样做,SBT会自动将您的Scala版本附加到工件.有关详细信息,请参见docs.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读