解决SBT依赖关系 [英] resolviing SBT dependencies

查看:351
本文介绍了解决SBT依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JVM开发的新手(我正在使用Scala和SBT),并且在解决依赖项方面遇到麻烦。昨天,我在解决 org.restlet.2.1.1 依赖性时遇到了麻烦,而今天,在解决以下问题时遇到了麻烦:

I am new to JVM development (I am using Scala and SBT) and am having trouble resolving dependencies. Yesterday, I had trouble resolving the org.restlet.2.1.1 dependency and today, I am having trouble with resolving the following:

[error] (*:update) sbt.ResolveException: unresolved dependency: com.mongodb.casbah#casbah_2.9.2;2.1.5-1: not found
[error] unresolved dependency: org.scalatra#scalatra_2.9.2;2.3.0: not found
[error] unresolved dependency: org.scalatra#scalatra-akka2_2.9.2;2.3.0: not found
[error] unresolved dependency: org.scalatra#scalatra-specs2_2.9.2;2.3.0: not found

我正在使用来自github的 giter8 scalatra-mongodb项目模板:点击我。由于该项目有些陈旧,因此有理由要尝试获取不再存在或不兼容的过时版本。在这种情况下,人该怎么办?我尝试摆弄 build.sbt 文件中的版本号,但这没有用(而且似乎更糟!)。

I am using a giter8 scalatra-mongodb project template from github: click me. Since the project is a little old, it stands to reason that I am trying to obtain outdated versions that no longer exist or are compatible. What does one do in this situation? I tried fiddling with the version numbers in my build.sbt file, but this did not work (and appears to be worse!).

以下是我的 build.sbt 文件的内容:

The following is the contents of my build.sbt file:

scalaVersion := "2.9.2"

mainClass := Some("JettyLauncher")

seq(webSettings :_*)

port in container.Configuration := 8080

seq(assemblySettings: _*)

libraryDependencies ++= Seq(
  "com.mongodb.casbah" %% "casbah" % "2.8.1-1",
  "org.scalatra" %% "scalatra" % "2.2.0",
  "org.scalatra" %% "scalatra-akka2" % "2.2.0",
  "org.scalatra" %% "scalatra-specs2" % "2.2.0" % "test",
  "org.mortbay.jetty" % "servlet-api" % "3.0.20100224" % "provided",
  "org.eclipse.jetty" % "jetty-server" % "8.0.0.M3" % "container, compile",
  "org.eclipse.jetty" % "jetty-util" % "8.0.0.M3" % "container, compile",
  "org.eclipse.jetty" % "jetty-webapp" % "8.0.0.M3" % "container, compile"
  )

resolvers ++= Seq(
  "Sonatype OSS" at "http://oss.sonatype.org/content/repositories/releases/",
  "Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/",
  "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/",
  "Akka Repo" at "http://akka.io/repository/",
  "Web plugin repo" at "http://siasia.github.com/maven2"
)

以下是我的 plugins.sbt 文件:

addSbtPlugin("com.earldouglas" %% "xsbt-web-plugin" % "0.9.0")

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.7.2")

请注意,当我第一次生成模板时,我收到的第一个插件缺少相关性。幸运的是,此插件的github页提供了更新的说明,我能够克服此依赖关系。

Note that when I first generated the template, I was receiving missing dependencies for this first plugin. Fortunately, the github page for this plugin gave updated instructions and I am able to get past this dependency.

无论如何,我需要获取这些依赖关系的版本是什么一切正常吗?总的来说,解决这些依赖关系的策略是什么(现在我不知道该怎么做(除了访问github页面并用版本号摆弄)?

Anyway, what are the versions of these dependencies that I need to get everything working? In general what is a strategy for resolving these dependencies (right now I have no idea what to do (other than visit the github pages and fiddle with version numbers)?

谢谢

推荐答案

我至少已经得到sbt来解决我依赖的东西,无论它是值得的(它都有类路径问题)现在...)。无论如何,以下是我新的和改进的 build.sbt 文件:

I have at least gotten sbt to resolve my dependencies for whatever that is worth (it has classpath issues now...). Anyway, the following is my new and improved build.sbt file:

scalaVersion := "2.10.4"

mainClass := Some("JettyLauncher")

seq(webSettings :_*)

port in container.Configuration := 8080

seq(assemblySettings: _*)

libraryDependencies +=  "org.mongodb" %% "casbah-core" % "2.7.3"

libraryDependencies += "org.scalatra" %% "scalatra" % "2.2.0-RC3" cross CrossVersion.binary

libraryDependencies +=  "org.scalatra" %% "scalatra-akka" % "2.2.0-RC3" 

libraryDependencies +=  "org.scalatra" %% "scalatra-specs2" % "2.2.0" % "test"

libraryDependencies +=  "org.mortbay.jetty" % "servlet-api" % "3.0.20100224" % "provided"

libraryDependencies +=  "org.eclipse.jetty" % "jetty-server" % "9.0.0.M5" % "container"

libraryDependencies +=  "org.eclipse.jetty" % "jetty-util" % "9.0.0.M5" % "container"

libraryDependencies +=  "org.eclipse.jetty" % "jetty-webapp" % "9.0.0.M5" % "container"

resolvers ++= Seq(
  "Sonatype releases" at "http://oss.sonatype.org/content/repositories/releases/",
  "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/",
  "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/",
  "Akka Repo" at "http://akka.io/repository/",
  "Web plugin repo" at "http://siasia.github.com/maven2"
)

我真正要做的就是花几个小时在谷歌上搜索并搜索与我使用的scala版本兼容的mvn存储库(2.10.4)。我了解到 %% 会将scala版本附加到依赖项名称(由于Scala一直在发展,这似乎是一个很好的约定)。一次,我解决了一些依赖关系,其余的解决了!

All I really did was spend a few hours googling and searching mvn repositories that were compatible with the scala version I am using (2.10.4). I learned that %% will append the scala-version to the dependency name (seems like a nice convention since Scala is always evolving). Once, I got a few dependencies resolved, the rest caved!

这篇关于解决SBT依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆