SBT 0.13.11无法下载代理后面的依赖项

时间:2016-05-25 14:54:41

标签: scala intellij-idea sbt

在代理服务器后面使用Windows 7,64位。

我已下载并安装了最新版本的SBT(0.13.11),Scala(2.11.8)和IntelliJ IDEA社区(2016.1.2)。当我尝试在IntelliJ中启动一个新项目时,我可以使用的最新版SBT是0.13.8,而不是0.13.11。有谁知道为什么会这样?如果我尝试启动一个新项目,我会收到一个错误:

  

错误:导入SBT项目时出错:
...

[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: org.scala-lang#scala-library;2.11.8: not found
[warn]  :: org.scala-lang#scala-compiler;2.11.8: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn] 
[warn]  Note: Unresolved dependencies path:
[warn]      org.scala-lang:scala-library:2.11.8 ((sbt.Classpaths) Defaults.scala#L1203)
[warn]        +- default:untitled1_2.11:1.0
[warn]      org.scala-lang:scala-compiler:2.11.8
[warn]        +- default:untitled1_2.11:1.0
[trace] Stack trace suppressed: run 'last *:update' for the full output.
[trace] Stack trace suppressed: run 'last :ssExtractDependencies' for the full output.
[error] (:update) sbt.ResolveException: unresolved dependency: org.scala-lang#scala-library;2.11.8: not found
[error] unresolved dependency: org.scala-lang#scala-compiler;2.11.8: not found
[error] (*:ssExtractDependencies) sbt.ResolveException: unresolved dependency: org.scala-lang#scala-library;2.11.8: not found
[error] unresolved dependency: org.scala-lang#scala-compiler;2.11.8: not found
[error] Total time: 4 s, completed May 25, 2016 10:51:00 AM
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=384M; support was removed in 8.0
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true

请参阅完整登录C:\ Users \ Rk.IdeaIC2016 \ system \日志\ sbt.last.log

经过一段时间的修补,我发现当我在终端输入sbt about时,我被告知我有SBT版本0.13.8,这是针对Scala 2.10.4构建的。这看起来不对劲!如果我进入IntelliJ并选择SBT构建为0.13.8并将Scala构建为2.10.4,则不会出现错误!!

所以,这很令人困惑,因为不清楚代理是否是问题。似乎我可以将SBT更新到0.13.11版本,整个过程都可行。

非常感谢任何见解或帮助 - 我很高兴学习Scala,但这些技术困难阻碍了我。

编辑:当我在项目目录中运行sbt compile时,我收到以下输出: enter image description here

3 个答案:

答案 0 :(得分:4)

你的sbt输出中有一条红线:

[error] Server access Error: Connection refused: connect url=https://repo1.maven.org/maven2/org/scala-lang/scala-library/2.11.8/scala-library-2.11.8.pom

之所以发生这种情况,是因为您在代理之后,从版本0.13.9开始,sbt默认使用https进行所有连接。 sbt 0.13.8仍然使用http,这就是为什么这个问题在这个版本中没有显示的原因。

解决此问题的最简单方法是修改sbt.bat脚本并在命令行中添加一个参数来启动sbt可执行文件:

-Dsbt.repository.secure=false

此命令强制sbt使用http。

看似更正确但更复杂的修复方法包括从您使用的maven存储库手动提取https证书,以及使用keytool将它们安装到JDK的cacerts密钥库中 - 但是这种复杂的方法并非如此似乎涵盖了所有情况,而完全关闭https就像魅力一样。

答案 1 :(得分:0)

假设您的<project-name>/project文件夹中有build.properties个文件,其中包含一个属性sbt.version=0.13.8

答案 2 :(得分:0)

使用错误配置的sbt 0.13.11似乎存在问题。我只能通过将https代理设置放入http参数来使其工作。

所以它确实对每个连接使用https但忽略了https代理参数。