在 sbt compile 上获取未解决的依赖关系

Getting unresolved dependencies on sbt compile


下面是我的 scalatra 项目中的 build.sbt 文件。当大多数依赖项得到解决时,由于 commons-codec 和 jetty 插件,构建失败:

import AssemblyKeys._ // put this at the top of the file

import NativePackagerKeys._

packageArchetype.java_server

assemblySettings

scalariformSettings

organization := "io.swagger"

seq(webSettings :_*)

mainClass in assembly := Some("JettyMain")

name := "scalatra-sample"

version := "0.1.0-SNAPSHOT"

scalaVersion := "2.11.2"

scalacOptions += "-language:postfixOps"

libraryDependencies ++= Seq(
  "org.scalatest"           %% "scalatest"                      % "2.2.1"               % "test",
  "org.scalatra"            %% "scalatra"                       % "2.3.0.RC3",
  "org.scalatra"            %% "scalatra-scalate"               % "2.3.0.RC3",
  "org.scalatra"            %% "scalatra-json"                  % "2.3.0.RC3",
  "org.scalatra"            %% "scalatra-swagger"               % "2.3.0.RC3",
  "org.scalatra"            %% "scalatra-swagger-ext"           % "2.3.0.RC3",
  "org.scalatra"            %% "scalatra-slf4j"                 % "2.3.0.RC3",
  "org.json4s"              %% "json4s-jackson"                 % "3.2.10",
  "org.json4s"              %% "json4s-ext"                     % "3.2.10",
  "commons-codec"            % "commons-codec"                  % "1.7",
  "net.databinder.dispatch" %% "dispatch-core"                  % "0.11.2",
  //"net.databinder.dispatch" %% "json4s-jackson"                 % "0.11.2",
  "net.databinder.dispatch" %% "dispatch-json4s-jackson"        % "0.11.2",
  "com.typesafe.akka"       %% "akka-actor"                     % "2.3.6",
  "org.eclipse.jetty"        % "jetty-server"                   % "9.2.3.v20140905" % "container;compile;test",
  "org.eclipse.jetty"        % "jetty-webapp"                   % "9.2.3.v20140905" % "container;compile;test",
  "org.eclipse.jetty.orbit"  % "javax.servlet"                  % "3.0.0.v201112011016" % "container;compile;provided;test" artifacts (Artifact("javax.servlet", "jar", "jar"))
)

resolvers += "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository"

resolvers += "Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"

resolvers += "Sonatype OSS Releases" at "http://oss.sonatype.org/content/repositories/releases/"

ivyXML := <dependencies>
    <exclude module="slf4j-log4j12"/>
    <exclude module="grizzled-slf4j_2.9.1"/>
    <exclude module="jsr311-api" />
  </dependencies>

mergeStrategy in assembly <<= (mergeStrategy in assembly) {
  (old) => {
    case "about.html"     => MergeStrategy.discard
    case x => old(x)
  }
}

net.virtualvoid.sbt.graph.Plugin.graphSettings

当我尝试 运行 sbt 编译时,出现以下错误。删除 .ivy 和 .sbt 后重试。仍然没有帮助:

        at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:217)
        at sbt.IvyActions$$anonfun$update.apply(IvyActions.scala:126)
        at sbt.IvyActions$$anonfun$update.apply(IvyActions.scala:125)
        at sbt.IvySbt$Module$$anonfun$withModule.apply(Ivy.scala:115)
        at sbt.IvySbt$Module$$anonfun$withModule.apply(Ivy.scala:115)
        at sbt.IvySbt$$anonfun$withIvy.apply(Ivy.scala:103)
        at sbt.IvySbt.sbt$IvySbt$$action(Ivy.scala:48)
        at sbt.IvySbt$$anon.call(Ivy.scala:57)
        at xsbt.boot.Locks$GlobalLock.withChannel(Locks.scala:93)
        at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries(Locks.scala:78)
        at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock.apply(Locks.scala:97)
        at xsbt.boot.Using$.withResource(Using.scala:10)
        at xsbt.boot.Using$.apply(Using.scala:9)
        at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:58)
        at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:48)
        at xsbt.boot.Locks$.apply0(Locks.scala:31)
        at xsbt.boot.Locks$.apply(Locks.scala:28)
        at sbt.IvySbt.withDefaultLogger(Ivy.scala:57)
        at sbt.IvySbt.withIvy(Ivy.scala:98)
        at sbt.IvySbt.withIvy(Ivy.scala:94)
        at sbt.IvySbt$Module.withModule(Ivy.scala:115)
        at sbt.IvyActions$.update(IvyActions.scala:125)
        at sbt.Classpaths$$anonfun$sbt$Classpaths$$work.apply(Defaults.scala:1223)
        at sbt.Classpaths$$anonfun$sbt$Classpaths$$work.apply(Defaults.scala:1221)
        at sbt.Classpaths$$anonfun$doWork$$anonfun.apply(Defaults.scala:1244)
        at sbt.Classpaths$$anonfun$doWork$$anonfun.apply(Defaults.scala:1242)
        at sbt.Tracked$$anonfun$lastOutput.apply(Tracked.scala:35)
        at sbt.Classpaths$$anonfun$doWork.apply(Defaults.scala:1246)
        at sbt.Classpaths$$anonfun$doWork.apply(Defaults.scala:1241)
        at sbt.Tracked$$anonfun$inputChanged.apply(Tracked.scala:45)
        at sbt.Classpaths$.cachedUpdate(Defaults.scala:1249)
        at sbt.Classpaths$$anonfun$updateTask.apply(Defaults.scala:1214)
        at sbt.Classpaths$$anonfun$updateTask.apply(Defaults.scala:1192)
        at scala.Function1$$anonfun$compose.apply(Function1.scala:47)
        at sbt.$tilde$greater$$anonfun$$u2219.apply(TypeFunctions.scala:42)
        at sbt.std.Transform$$anon.work(System.scala:64)
        at sbt.Execute$$anonfun$submit$$anonfun$apply.apply(Execute.scala:237)
        at sbt.Execute$$anonfun$submit$$anonfun$apply.apply(Execute.scala:237)
        at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
        at sbt.Execute.work(Execute.scala:244)
        at sbt.Execute$$anonfun$submit.apply(Execute.scala:237)
        at sbt.Execute$$anonfun$submit.apply(Execute.scala:237)
        at sbt.ConcurrentRestrictions$$anon$$anonfun.apply(ConcurrentRestrictions.scala:160)
        at sbt.CompletionService$$anon.call(CompletionService.scala:30)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
[error] (*:update) sbt.ResolveException: unresolved dependency: org.slf4j#slf4j-api;1.7.7: several problems occurred while resolving dependency: org.slf4j#slf4j-api;1.7.7 {compile=
[compile(*), master(*)], runtime=[runtime(*)]}:
[error]         several problems occurred while resolving dependency: org.slf4j#slf4j-parent;1.7.7 {}:
[error]         URI has an authority component
[error]         URI has an authority component
[error]         URI has an authority component
[error] unresolved dependency: commons-validator#commons-validator;1.4.0: several problems occurred while resolving dependency: commons-validator#commons-validator;1.4.0 {compile=[
compile(*), master(*)], runtime=[runtime(*)]}:
[error]         several problems occurred while resolving dependency: org.apache.commons#commons-parent;23 {}:
[error]         URI has an authority component
[error]         URI has an authority component
[error]         URI has an authority component
[error] unresolved dependency: com.fasterxml.jackson.core#jackson-databind;2.3.1: several problems occurred while resolving dependency: com.fasterxml.jackson.core#jackson-databind;
2.3.1 {compile=[compile(*), master(*)], runtime=[runtime(*)]}:
[error]         several problems occurred while resolving dependency: com.fasterxml#oss-parent;12 {}:
[error]         URI has an authority component
[error]         URI has an authority component
[error]         URI has an authority component
[error] unresolved dependency: commons-codec#commons-codec;1.7: several problems occurred while resolving dependency: commons-codec#commons-codec;1.7 {compile=[default(compile)]}:
[error]         several problems occurred while resolving dependency: org.apache.commons#commons-parent;26 {}:
[error]         URI has an authority component
[error]         URI has an authority component
[error]         URI has an authority component
[error] unresolved dependency: org.eclipse.jetty#jetty-server;9.2.3.v20140905: several problems occurred while resolving dependency: org.eclipse.jetty#jetty-server;9.2.3.v20140905
{container=[default(compile)], compile=[default(compile)], test=[default(compile)]}:
[error]         several problems occurred while resolving dependency: org.eclipse.jetty#jetty-project;9.2.3.v20140905 {}:
[error]         URI has an authority component
[error]         URI has an authority component
[error]         URI has an authority component
[error] unresolved dependency: org.eclipse.jetty#jetty-webapp;9.2.3.v20140905: several problems occurred while resolving dependency: org.eclipse.jetty#jetty-webapp;9.2.3.v20140905
{container=[default(compile)], compile=[default(compile)], test=[default(compile)]}:
[error]         several problems occurred while resolving dependency: org.eclipse.jetty#jetty-project;9.2.3.v20140905 {}:
[error]         URI has an authority component
[error]         URI has an authority component
[error]         URI has an authority component
[error] unresolved dependency: org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016: several problems occurred while resolving dependency: org.eclipse.jetty.orbit#javax.servle
t;3.0.0.v201112011016 {container=[default(compile)], compile=[default(compile)], provided=[default(compile)], test=[default(compile)]}:
[error]         several problems occurred while resolving dependency: org.eclipse.jetty.orbit#jetty-orbit;1 {}:
[error]         URI has an authority component
[error]         URI has an authority component
[error]         URI has an authority component

此 build.sbt 由 swagger-scalatra 模板自动生成

你的问题似乎都与URI has an authority component有关。这是 URI 的 host:port 部分,您的错误表明依赖项解析不期望一个。

我觉得你对Maven local的定义有问题。尝试删除它并重新运行,并尝试用这个替换它。

resolvers += Resolver.mavenLocal