当前位置: 首页 > 知识库问答 >
问题:

第一次使用SBT-在代理后检索依赖项

拓拔骁
2023-03-14

我已经下载了SBT(sbt-0.13.15.zip)并解压缩了它,但是我在运行SBT.bat时遇到了问题。

最初,当我发现只需要指定https配置而不是http配置时,我修复了代理问题--当同时提供这两个配置时,它使用了http配置,但它失败了。

因此,现在我不再有代理问题了,但它在尝试获取jansi依赖项时失败了:

setting 'basedir' to 'C:\Users\vfuchs070114\.sbt\boot'
:: resolving dependencies :: org.scala-sbt#boot-jansi;1.0
    confs: [default]
    validate = true
    refresh = false
resolving dependencies for configuration 'default'
== resolving dependencies for org.scala-sbt#boot-jansi;1.0 [default]
loadData of org.scala-sbt#boot-jansi;1.0 of rootConf=default
== resolving dependencies org.scala-sbt#boot-jansi;1.0->org.fusesource.jansi#jansi;1.11 [default->default(compile)]
loadData of org.fusesource.jansi#jansi;1.11 of rootConf=default
    using redefined-public to resolve org.fusesource.jansi#jansi;1.11
redefined-public: Checking cache for: dependency: org.fusesource.jansi#jansi;1.11 {default=[default(compile)]}
redefined-public: no namespace defined: using system
    no ivy file in cache for org.fusesource.jansi#jansi;1.11: tried C:\Users\vfuchs070114\.ivy2\cache\org.fusesource.jansi\jansi\ivy-1.11.xml
redefined-public: no latest strategy defined: using default
local: no namespace defined: using system
    no ivy file in cache for org.fusesource.jansi#jansi;1.11: tried C:\Users\vfuchs070114\.ivy2\cache\org.fusesource.jansi\jansi\ivy-1.11.xml
     trying C:\Users\vfuchs070114\.ivy2\local\org.fusesource.jansi\jansi\1.11\ivys\ivy.xml
        tried C:\Users\vfuchs070114\.ivy2\local\org.fusesource.jansi\jansi\1.11\ivys\ivy.xml
    local: resource not reachable for org.fusesource.jansi#jansi;1.11: res=C:\Users\vfuchs070114\.ivy2\local\org.fusesource.jansi\jansi\1.11\ivys\ivy.xml
     trying C:\Users\vfuchs070114\.ivy2\local\org.fusesource.jansi\jansi\1.11\jars\jansi.jar
        tried C:\Users\vfuchs070114\.ivy2\local\org.fusesource.jansi\jansi\1.11\jars\jansi.jar
    local: resource not reachable for org.fusesource.jansi#jansi;1.11: res=C:\Users\vfuchs070114\.ivy2\local\org.fusesource.jansi\jansi\1.11\jars\jansi.jar
    local: no ivy file nor artifact found for org.fusesource.jansi#jansi;1.11
local-preloaded-ivy: no namespace defined: using system
    no ivy file in cache for org.fusesource.jansi#jansi;1.11: tried C:\Users\vfuchs070114\.ivy2\cache\org.fusesource.jansi\jansi\ivy-1.11.xml
     trying file:/C:/Users/vfuchs070114/.sbt/preloaded/org.fusesource.jansi/jansi/1.11/ivys/ivy.xml
        tried file:/C:/Users/vfuchs070114/.sbt/preloaded/org.fusesource.jansi/jansi/1.11/ivys/ivy.xml
    local-preloaded-ivy: resource not reachable for org.fusesource.jansi#jansi;1.11: res=file:/C:/Users/vfuchs070114/.sbt/preloaded/org.fusesource.jansi/jansi/1.11/ivys/ivy.xml
    local-preloaded-ivy: no ivy file found for org.fusesource.jansi#jansi;1.11
local-preloaded: no namespace defined: using system
    no ivy file in cache for org.fusesource.jansi#jansi;1.11: tried C:\Users\vfuchs070114\.ivy2\cache\org.fusesource.jansi\jansi\ivy-1.11.xml
     trying file:/C:/Users/vfuchs070114/.sbt/preloaded/org/fusesource/jansi/jansi/1.11/jansi-1.11.pom
        tried file:/C:/Users/vfuchs070114/.sbt/preloaded/org/fusesource/jansi/jansi/1.11/jansi-1.11.pom
    local-preloaded: resource not reachable for org/fusesource/jansi#jansi;1.11: res=file:/C:/Users/vfuchs070114/.sbt/preloaded/org/fusesource/jansi/jansi/1.11/jansi-1.11.pom
     trying file:/C:/Users/vfuchs070114/.sbt/preloaded/org/fusesource/jansi/jansi/1.11/jansi-1.11.jar
        tried file:/C:/Users/vfuchs070114/.sbt/preloaded/org/fusesource/jansi/jansi/1.11/jansi-1.11.jar
    local-preloaded: resource not reachable for org/fusesource/jansi#jansi;1.11: res=file:/C:/Users/vfuchs070114/.sbt/preloaded/org/fusesource/jansi/jansi/1.11/jansi-1.11.jar
    local-preloaded: no ivy file nor artifact found for org.fusesource.jansi#jansi;1.11
Maven Central: no namespace defined: using system
    no ivy file in cache for org.fusesource.jansi#jansi;1.11: tried C:\Users\vfuchs070114\.ivy2\cache\org.fusesource.jansi\jansi\ivy-1.11.xml
     trying https://repo1.maven.org/maven2/org/fusesource/jansi/jansi/1.11/jansi-1.11.pom
        tried https://repo1.maven.org/maven2/org/fusesource/jansi/jansi/1.11/jansi-1.11.pom
problem occurred while resolving dependency: org.fusesource.jansi#jansi;1.11 {default=[default(compile)]} with Maven Central: java.lang.RuntimeException: java.util.NoSuchElementException
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1453)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439)
    at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:2965)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:489)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)
    at org.apache.ivy.util.url.BasicURLHandler.checkStatusCode(BasicURLHandler.java:130)
    at org.apache.ivy.util.url.BasicURLHandler.getURLInfo$57a0216e(BasicURLHandler.java:73)
    at org.apache.ivy.util.url.BasicURLHandler.getURLInfo(BasicURLHandler.java:54)
    at org.apache.ivy.plugins.repository.url.URLResource.init(URLResource.java:65)
    at org.apache.ivy.plugins.repository.url.URLResource.exists(URLResource.java:81)
    at org.apache.ivy.plugins.resolver.RepositoryResolver.findResourceUsingPattern(RepositoryResolver.java:97)
    at org.apache.ivy.plugins.resolver.AbstractPatternsBasedResolver.findResourceUsingPatterns(AbstractPatternsBasedResolver.java:96)
    at org.apache.ivy.plugins.resolver.IBiblioResolver.findIvyFileRef(IBiblioResolver.java:102)
    at org.apache.ivy.plugins.resolver.BasicResolver.getDependency(BasicResolver.java:228)
    at org.apache.ivy.plugins.resolver.IBiblioResolver.getDependency(IBiblioResolver.java:512)
    at org.apache.ivy.plugins.resolver.ChainResolver.getDependency(ChainResolver.java:104)
    at org.apache.ivy.core.resolve.IvyNode.loadData(IvyNode.java:169)
    at org.apache.ivy.core.resolve.VisitNode.loadData(VisitNode.java:292)
    at org.apache.ivy.core.resolve.ResolveEngine.fetchDependencies(ResolveEngine.java:714)
    at org.apache.ivy.core.resolve.ResolveEngine.doFetchDependencies(ResolveEngine.java:799)
    at org.apache.ivy.core.resolve.ResolveEngine.fetchDependencies(ResolveEngine.java:722)
    at org.apache.ivy.core.resolve.ResolveEngine.getDependencies(ResolveEngine.java:594)
    at org.apache.ivy.core.resolve.ResolveEngine.resolve(ResolveEngine.java:234)
    at xsbt.boot.Update.xsbt$boot$Update$$lockedApply(Update.scala:105)
    at xsbt.boot.Update$$anon$4.call(Update.scala:99)
    at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:93)
    at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:78)
    at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.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 xsbt.boot.Update.apply(Update.scala:100)
    at xsbt.boot.Launch.update(Launch.scala:352)
    at xsbt.boot.Launch$$anonfun$jansiLoader$1.apply(Launch.scala:178)
    at scala.Option.getOrElse(Option.scala:120)
    at xsbt.boot.Launch.jansiLoader$2f324eef(Launch.scala:173)
    at xsbt.boot.Launch.<init>(Launch.scala:150)
    at xsbt.boot.Launcher$.apply(Launch.scala:366)
    at xsbt.boot.Launch$.apply(Launch.scala:18)
    at xsbt.boot.Boot$.runImpl(Boot.scala:41)
    at xsbt.boot.Boot$.main(Boot.scala:17)
    at xsbt.boot.Boot.main(Boot.scala)
Caused by: java.util.NoSuchElementException
    at java.util.StringTokenizer.nextToken(StringTokenizer.java:349)
    at sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:2016)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:183)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1511)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
    ... 41 more

它试图从https://repo1.maven.org/maven2/org/fusesource/jansi/jansi/1.11/jansi-1.11.pom中获取存在的数据,但似乎无法解析它或其他东西(StringTokenizer引发的NoSuchElementException)。我试着将pom和jar文件放在local中,在那里它会找到它们:它会找到它们,但在结束时并没有太大的区别。

类似的情况也发生在typesafe-ivy-releases和sbt-ivy-snapshot,它试图从不存在的远程URL获取一些ivy信息:

>

  • https://repo.typesafe.com/typesafe/ivy-releases/org.fusesource.jansi/jansi/1.11/ivys/ivy.xml

    https://repo.scala-sbt.org/scalasbt/ivy-snapshots/org.fusesource.jansi/jansi/1.11/ivys/ivy.xml

    所以在这种情况下,它失败并不是一个重大的意外。

    编辑

    我在https://github.com/typesafehub/activator/issues/18中看到,这可能是Ipv4/Ipv6的问题。我尝试向IPv4(-djava.net.preferIPv4Stack=true)添加推荐属性以强制,但仍然不起作用。

    然而,我觉得根本原因可能是这样的,或者是某种编码问题,使得远程文件“不可解析”。

    编辑2

    昨天我花了一整天的时间手动获取依赖项,但到最后它仍然不能工作。然后我在没有代理的情况下在家里的电脑上试了一下,它工作得很完美。所以现在我再次尝试,只专注于运行sbt.bat:我在java调用之前在sbt.bat中添加了一个“echo”,以确保它具有我所期望的内容,它确实做到了:

    "C:\Toolbox\apps\jdk\jdk1.8.0_25-windows-x64\bin\java.exe" -Dhttps.proxyHost=theProxyURL 
    -Dhttps.proxyPort=8080 -Dhttps.proxyUser=myId -Dhttps.proxyPassword=myPassword
    -cp "C:\Toolbox\apps\sbt-0.13.15_2ndTry\bin\sbt-launch.jar" xsbt.boot.Boot  
    

    但我还是有问题..如果这是一个证书或类似的问题,我应该得到一个更清楚的信息,对吗?

    实际上存在几个与代理相关的打开问题:https://github.com/sbt/sbt/issues?utf8=%e2%9c%93&q=is%3aissues%20is%3aopen%20proxy

    我现在正在考虑的一件事是配置代理存储库:http://www.scala-sbt.org/0.13/docs/proxy-repositories.html(我们使用Nexus)

  • 共有1个答案

    贲宜春
    2023-03-14

    尽管我还没能找到我最初问题的明确答案,但我还是学到了一些东西:

    >

  • 在企业internet代理后使用SBT的解决方案是使用内部Nexus代理:为什么SBT要尝试下载不存在的依赖项?

    SBT日志记录并不是很有帮助,而且同一个错误消息可能有几十个实际的失败原因。

    根据配置的依赖存储库(http://www.scala-sbt.org/0.13/docs/proxy-repositories.html),SBT将尝试基于各种命名约定(Ivy和Maven)的所有类型的UR。这就是为什么有时URL根本不存在的原因。

  •  类似资料:
    • 使用Windows7,64bit,在代理服务器后面。 我已经下载并安装了SBT(0.13.11)、Scala(2.11.8)和IntelliJ IDEA社区(2016.1.2)的最新版本。当我尝试在IntelliJ中启动一个新项目时,我可以使用的SBT的最新版本是0.13.8,而不是0.13.11。有人知道为什么会这样吗?如果我尝试启动一个新项目,我会得到一个错误: 错误:导入SBT项目时出错:

    • 我试图构建一个具有spark依赖关系的非常基本的scala脚本。但我不能用它做罐子。 我的scala源代码在: /exampleapp/main/scala/example/hello.scala 项目名为exampleapp。

    • 我有一个sbt插件项目,使用多项目构建。我想使用这个插件作为其他sbt项目的依赖项。我已经创建了一个插件,但是当我把这个插件添加到project中时,我似乎不能正确地连接依赖项。 我在这里漏掉了什么?

    • 我需要为我的一个子项目构建一个jar,包括依赖项,以便它可以用作。 我有一个多模块的sbt项目,这个模块是最低级别的(也是纯Java)。 我可以(例如使用sbt-onejar、sbt-proGuard或sbt组件)覆盖最低级别模块的打包方式吗? 看起来这些工具真的被设计成发布后的步骤,但是我真的需要一个(替换或附加的)发布的人工制品来包含依赖项(但只适用于这一个模块)。 更新:发布sbt程序集是针

    • ::使用详细或调试消息级别获取更多详细信息未解决的依赖关系:org.scala-sbt#sbt;0.13.6:在sbt执行期间未找到错误:检索所需库时出错(有关完整日志,请参阅/home/vibhanshu/.sbt/boot/update.log)错误:无法检索sbt 0.13.6