首页 文章

为什么SBT无法解决我的依赖?

提问于
浏览
2

由于某种原因,我需要使用Maven Central已删除jar的JMS 1.1 .

我将JBoss存储库添加到我的存储库列表中:

resolvers += "JBoss" at "https://repository.jboss.org/nexus/content/groups/public"

,但是当我尝试使用0.13.1构建时,我收到以下错误:

25-Feb-2014 19:22:41    [warn]         [NOT FOUND  ] javax.jms#jms;1.1!jms.jar (0ms)
25-Feb-2014 19:22:41    [warn] ==== public: tried
25-Feb-2014 19:22:41    [warn]   http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.jar
25-Feb-2014 19:22:41    [warn]         ::::::::::::::::::::::::::::::::::::::::::::::
25-Feb-2014 19:22:41    [warn]         ::              FAILED DOWNLOADS            ::
25-Feb-2014 19:22:41    [warn]         :: ^ see resolution messages for details  ^ ::
25-Feb-2014 19:22:41    [warn]         ::::::::::::::::::::::::::::::::::::::::::::::
25-Feb-2014 19:22:41    [warn]         :: javax.jms#jms;1.1!jms.jar
25-Feb-2014 19:22:41    [warn]         ::::::::::::::::::::::::::::::::::::::::::::::
25-Feb-2014 19:22:41    [info] Wrote /appdata/liquidnet/data/BambooAgent/build-dir/TICKDB-SP-JOB1/src/target/scala-2.10/pretrade-scala_2.10-1.0.pom
25-Feb-2014 19:22:41    sbt.ResolveException: download failed: javax.jms#jms;1.1!jms.jar

我看到了关于设置externalResolvers的一些内容,所以它不使用Maven中心,但我实际上喜欢将Maven中心用于我拥有的所有其他依赖项 .

我发出 last *:update 时会看到以下内容

[info] Resolving javax.jms#jms;1.1 ...
[debug] sbt-chain: Checking cache for: dependency: javax.jms#jms;1.1 {compile=[default(compile)]}
[debug]                 tried /home/dnugent/.ivy2/local/javax.jms/jms/1.1/ivys/ivy.xml
[debug]         local: no ivy file found for javax.jms#jms;1.1
[debug]                 tried http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.pom
[debug]         public: found md file for javax.jms#jms;1.1
[debug]                 => http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.pom (1.1)
[debug] downloading http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.pom ...
[debug]         public: downloading http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.pom
[debug]         public: downloading http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.pom.sha1
[debug] sha1 OK for http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.pom
[debug]         [SUCCESSFUL ] javax.jms#jms;1.1!jms.pom(pom.original) (121ms)
[debug]                 tried /home/dnugent/.ivy2/local/javax.jms/jms/1.1/jars/jms.jar
[debug]                 tried http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.jar
[debug] CLIENT ERROR: Not Found url=http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.jar
[debug]                 tried https://repository.jboss.org/nexus/content/groups/public/javax/jms/jms/1.1/jms-1.1.jar
[debug]         found javax.jms#jms;1.1 in public

JMS 1.1 Jar绝对是JBoss的回购,所以我在这里继续进行 .

2 回答

  • 4

    正如我在the ticket you opened中解释的那样,正在发生的事情是Ivy在特定的解析器中找到 pom.xml 文件(在本例中是maven-central)但是无法在那里找到jar文件 . 这导致常 Spring 藤完全放弃分辨率,而不仅仅是将解析器标记为坏并继续前进 .

    您需要做的是确保在"bad"解析器之前订购所需的"good"解析器 . 您可以通过 show fullResolvers 命令查看sbt将要使用的resovlers的有序列表 . 这是一个例子:

    > show fullResolvers
    [info] ArrayBuffer(Raw(ProjectResolver(inter-project, mapped: )), URLRepository(typesafe-ivy-releases,Patterns(ivyPatterns=List(http://repo.typesafe.com/typesafe/ivy-releases/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), artifactPatterns=List(http://repo.typesafe.com/typesafe/ivy-releases/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), isMavenCompatible=false, descriptorOptional=false, skipConsistencyCheck=false)), URLRepository(sbt-plugin-releases,Patterns(ivyPatterns=List(http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), artifactPatterns=List(http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), isMavenCompatible=false, descriptorOptional=false, skipConsistencyCheck=false)), FileRepository(local,FileConfiguration(true,None),Patterns(ivyPatterns=List(${ivy.home}/local/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), artifactPatterns=List(${ivy.home}/local/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), isMavenCompatible=false, descriptorOptional=false, skipConsistencyCheck=false)), public: http://repo1.maven.org/maven2/)
    

    不幸的是,这个输出现在对人类来说是不可读的 . (请打开 export 命令的票证以支持 fullResolvers ,我将来可以改进调试) . 但是,我们可以做一些穷人的调试,将其添加到 build.sbt

    val exportFullResolvers = taskKey[Unit]("debug resolvers")
    
    exportFullResolvers := {
      for {
       (resolver,idx) <- fullResolvers.value.zipWithIndex
      } println(s"${idx}.  ${resolver.name}")
    }
    

    现在,你可以在你的sbt构建中运行这个任务来找出/玩具解析器的顺序:

    > exportFullResolvers
    0.  inter-project
    1.  typesafe-ivy-releases
    2.  sbt-plugin-releases
    3.  local
    4.  public
    [success] Total time: 0 s, completed Feb 26, 2014 6:10:07 PM
    

    您需要修改解析器,以便项目间首先出现,但"public"(maven central)位于jboss解析器之后 . 您可以通过以下方式在build.sbt中内联修改resovlers:

    fullResolvers := {
      val previous = fullResolvers.value
      previous.sortWith { (lhs, rhs) =>  ??? /* You define something here */ }
    }
    
  • 0

    你需要覆盖解析器设置而不是附加到它的引用:SBT won't resolve transitive dependency against any repository except Typesafe's

    为我工作 . 如果SBT团队的任何人看到这个,看起来像一个bug .

相关问题