resolviing SBT dependencies

2019-09-08 04:35发布

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

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!).

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"
)

The following is my plugins.sbt file:

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

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

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.

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)?

Thanks for all the help!

1条回答
走好不送
2楼-- · 2019-09-08 05:38

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"
)

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!

查看更多
登录 后发表回答