IntelliJ的SBT代理设置

时间:2018-02-23 19:46:40

标签: scala intellij-idea sbt

我试图在Windows 7中使用IntelliJ的Scala / Spark,但IntelliJ(和SBT命令行)无法下载文件。我在代理服务器后面。

        [info] Updating {file:/D:/Users/user1/IdeaProjects/untitled17/project/}untitled17-build...
        [warn]  [FAILED     ] org.apache.logging.log4j#log4j-core;2.8.1!log4j-core.jar(test-jar): typesafe-ivy-releases: unable to get resource for org.apache.logging.log4j#log4j-core;2.8.1: res=https://repo.typesafe.com/typesafe/ivy-releases/org.apache.logging.log4j/log4j-core/2.8.1/test-jars/log4j-core-tests.jar: java.io.IOException: Failed to authenticate with proxy (452ms)
        [warn]  [FAILED     ] org.apache.logging.log4j#log4j-core;2.8.1!log4j-core.jar(test-jar): sbt-plugin-releases: unable to get resource for org.apache.logging.log4j#log4j-core;2.8.1: res=https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.apache.logging.log4j/log4j-core/2.8.1/test-jars/log4j-core-tests.jar: java.io.IOException: Failed to authenticate with proxy (157ms)
        [warn]  [FAILED     ] org.apache.logging.log4j#log4j-core;2.8.1!log4j-core.jar(test-jar): public: unable to get resource for org/apache/logging/log4j#log4j-core;2.8.1: res=https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-core/2.8.1/log4j-core-2.8.1-tests.jar: java.io.IOException: Failed to authenticate with proxy (115ms)
        [warn]  Detected merged artifact: [FAILED     ] org.apache.logging.log4j#log4j-core;2.8.1!log4j-core.jar(test-jar):  (0ms).
        [warn] ==== typesafe-ivy-releases: tried
        [warn] ==== sbt-plugin-releases: tried
        [warn]   https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.apache.logging.log4j/log4j-core/2.8.1/test-jars/log4j-core-tests.jar
        [warn] ==== local: tried
        [warn]   d:\Users\user1\.ivy2\local\org.apache.logging.log4j\log4j-core\2.8.1\test-jars\log4j-core-tests.jar
        [warn] ==== public: tried
        [warn]   https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-core/2.8.1/log4j-core-2.8.1-tests.jar
        [warn] ==== local-preloaded-ivy: tried
        [warn]   d:\Users\user1\.sbt\preloaded\org.apache.logging.log4j\log4j-core\2.8.1\test-jars\log4j-core-tests.jar
        [warn] ==== local-preloaded: tried
        [warn]   file:/d:/Users/user1/.sbt/preloaded/org/apache/logging/log4j/log4j-core/2.8.1/log4j-core-2.8.1-tests.jar
        [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
        [warn]  ::              FAILED DOWNLOADS            ::
        [warn]  :: ^ see resolution messages for details  ^ ::
        [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
        [warn]  :: org.apache.logging.log4j#log4j-core;2.8.1!log4j-core.jar(test-jar)
        [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
        [error] sbt.librarymanagement.ResolveException: download failed: org.apache.logging.log4j#log4j-core;2.8.1!log4j-core.jar(test-jar)

已经报告了类似的问题here

已经尝试过:

  • SBT版本0.13.16,1.0.3和1.1.1

  • 设置代理属性JAVA_OPTS,SBT_OPTS,sbtconfigtxt

        -Dhttp.proxyHost=*
        -Dhttp.proxyPort=*
        -Dhttp.proxyUser=*
        -Dhttp.proxyPassword=*
        -Dhttps.proxyHost=*
        -Dhttps.proxyPort=*
        -Dhttps.proxyUser=*
        -Dhttps.proxyPassword=*
    

    没有成功

  • 在SBT验证了这个问题:

        d:\Users\user1>sbt.bat
        [info] Loading project definition from D:\Users\user1\project
        [info] Updating {file:/D:/Users/user1/project/}user1-build...
        [warn]  [FAILED     ] org.apache.logging.log4j#log4j-core;2.8.1!log4j-core.jar(t
        est-jar): typesafe-ivy-releases: unable to get resource for org.apache.logging.l
        og4j#log4j-core;2.8.1: res=https://repo.typesafe.com/typesafe/ivy-releases/org.a
        pache.logging.log4j/log4j-core/2.8.1/test-jars/log4j-core-tests.jar: java.io.IOE
        xception: Failed to authenticate with proxy (353ms)
        [warn]  [FAILED     ] org.apache.logging.log4j#log4j-core;2.8.1!log4j-core.jar(t
        est-jar): sbt-plugin-releases: unable to get resource for org.apache.logging.log
        4j#log4j-core;2.8.1: res=https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases
        /org.apache.logging.log4j/log4j-core/2.8.1/test-jars/log4j-core-tests.jar: java.
        io.IOException: Failed to authenticate with proxy (8ms)
        [warn]  [FAILED     ] org.apache.logging.log4j#log4j-core;2.8.1!log4j-core.jar(t
        est-jar): public: unable to get resource for org/apache/logging/log4j#log4j-core
        ;2.8.1: res=https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-core/2
        .8.1/log4j-core-2.8.1-tests.jar: java.io.IOException: Failed to authenticate wit
        h proxy (8ms)
        [warn]  Detected merged artifact: [FAILED     ] org.apache.logging.log4j#log4j-c
        ore;2.8.1!log4j-core.jar(test-jar):  (0ms).
        [warn] ==== typesafe-ivy-releases: tried
        [warn] ==== sbt-plugin-releases: tried
        [warn]   https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.apache.logg
        ing.log4j/log4j-core/2.8.1/test-jars/log4j-core-tests.jar
        [warn] ==== local: tried
        [warn]   d:\Users\user1\.ivy2\local\org.apache.logging.log4j\log4j-core\2.8.1\
        test-jars\log4j-core-tests.jar
        [warn] ==== public: tried
        [warn]   https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-core/2.8.
        1/log4j-core-2.8.1-tests.jar
        [warn] ==== local-preloaded-ivy: tried
        [warn]   d:\Users\user1\.sbt\preloaded\org.apache.logging.log4j\log4j-core\2.8
        .1\test-jars\log4j-core-tests.jar
        [warn] ==== local-preloaded: tried
        [warn]   file:/d:/Users/user1/.sbt/preloaded/org/apache/logging/log4j/log4j-co
        re/2.8.1/log4j-core-2.8.1-tests.jar
        [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
        [warn]  ::              FAILED DOWNLOADS            ::
        [warn]  :: ^ see resolution messages for details  ^ ::
        [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
        [warn]  :: org.apache.logging.log4j#log4j-core;2.8.1!log4j-core.jar(test-jar)
        [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
        [error] sbt.librarymanagement.ResolveException: download failed: org.apache.logg
        ing.log4j#log4j-core;2.8.1!log4j-core.jar(test-jar)
        [error]         at sbt.internal.librarymanagement.IvyActions$.resolveAndRetrieve
        (IvyActions.scala:331)
        [error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$updateEit
        her$1(IvyActions.scala:205)
        [error]         at sbt.internal.librarymanagement.IvySbt$Module.$anonfun$withMod
        ule$1(Ivy.scala:229)
        [error]         at sbt.internal.librarymanagement.IvySbt.$anonfun$withIvy$1(Ivy.
        scala:190)
        [error]         at sbt.internal.librarymanagement.IvySbt.sbt$internal$libraryman
        agement$IvySbt$$action$1(Ivy.scala:70)
        [error]         at sbt.internal.librarymanagement.IvySbt$$anon$3.call(Ivy.scala:
        77)
        [error]         at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:95)
        [error]         at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withCh
        annelRetries$1(Locks.scala:80)
        [error]         at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Lock
        s.scala:99)
        [error]         at xsbt.boot.Using$.withResource(Using.scala:10)
        [error]         at xsbt.boot.Using$.apply(Using.scala:9)
        [error]         at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scal
        a:60)
        [error]         at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:50)
        [error]         at xsbt.boot.Locks$.apply0(Locks.scala:31)
        [error]         at xsbt.boot.Locks$.apply(Locks.scala:28)
        [error]         at sbt.internal.librarymanagement.IvySbt.withDefaultLogger(Ivy.s
        cala:77)
        [error]         at sbt.internal.librarymanagement.IvySbt.withIvy(Ivy.scala:185)
        [error]         at sbt.internal.librarymanagement.IvySbt.withIvy(Ivy.scala:182)
        [error]         at sbt.internal.librarymanagement.IvySbt$Module.withModule(Ivy.s
        cala:228)
        [error]         at sbt.internal.librarymanagement.IvyActions$.updateEither(IvyAc
        tions.scala:190)
        [error]         at sbt.librarymanagement.ivy.IvyDependencyResolution.update(IvyD
        ependencyResolution.scala:20)
        [error]         at sbt.librarymanagement.DependencyResolution.update(DependencyR
        esolution.scala:56)
        [error]         at sbt.internal.LibraryManagement$.resolve$1(LibraryManagement.s
        cala:38)
        [error]         at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$12(Libr
        aryManagement.scala:91)
        [error]         at sbt.util.Tracked$.$anonfun$lastOutput$1(Tracked.scala:68)
        [error]         at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$19(Libr
        aryManagement.scala:104)
        [error]         at scala.util.control.Exception$Catch.apply(Exception.scala:224)
    
        [error]         at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$11(Libr
        aryManagement.scala:104)
        [error]         at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$11$adap
        ted(LibraryManagement.scala:87)
        [error]         at sbt.util.Tracked$.$anonfun$inputChanged$1(Tracked.scala:149)
        [error]         at sbt.internal.LibraryManagement$.cachedUpdate(LibraryManagemen
        t.scala:118)
        [error]         at sbt.Classpaths$.$anonfun$updateTask$5(Defaults.scala:2353)
        [error]         at scala.Function1.$anonfun$compose$1(Function1.scala:44)
        [error]         at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFuncti
        ons.scala:42)
        [error]         at sbt.std.Transform$$anon$4.work(System.scala:64)
        [error]         at sbt.Execute.$anonfun$submit$2(Execute.scala:257)
        [error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.sc
        ala:16)
        [error]         at sbt.Execute.work(Execute.scala:266)
        [error]         at sbt.Execute.$anonfun$submit$1(Execute.scala:257)
        [error]         at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(Con
        currentRestrictions.scala:167)
        [error]         at sbt.CompletionService$$anon$2.call(CompletionService.scala:32
        )
        [error]         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        [error]         at java.util.concurrent.Executors$RunnableAdapter.call(Executors
        .java:511)
        [error]         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        [error]         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolE
        xecutor.java:1149)
        [error]         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPool
        Executor.java:624)
        [error]         at java.lang.Thread.run(Thread.java:748)
        Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? [error] (*:update)
         sbt.librarymanagement.ResolveException: download failed: org.apache.logging.log
        4j#log4j-core;2.8.1!log4j-core.jar(test-jar)
    

3 个答案:

答案 0 :(得分:3)

如果您确信这是代理问题(而不是,例如,临时网络连接问题),那么这是您的替代方案......

如您所述,您可以定义一个JVM_OPTS环境变量,指定 JVM 代理配置选项。为了清楚起见,最好是全局定义(通过 Windows系统小程序中的环境变量对话框,因为它看起来像是在使用 Windows )。如果您不确定如何操作,请告诉我。 重要的是要意识到您的现有流程选择对全局环境变量进行的更改 - 最简单的解决方案就是关闭并重新启动它们。

另一种方法是将 JVM 选项放入 SBT 项目的根文件夹中的.jvmopts文件中。 (将特定于项目的 JVM 选项放在此文件中是一个好主意,但将机器或特定于站点的选项(如代理设置)放入此类文件中并不是一个好主意。 ,如果您需要登录凭据来配置代理,请不要使用此路由!)如果选择此选项,则需要在文件的每一行上进行一次设置。每次运行时, SBT 都会读取任何此类设置。

无论哪种方式,您的问题都不清楚您是否正确指定了 JVM 代理设置,因为*不是其中任何一个的有效值。 (如果您刚刚使用*来替换您的实际设置,那么公平。)您最了解代理设置应该是什么,但是 - 如果您在中为您的计算机设置系统代理设置Windows - 通常配置 Java 应用程序以使用代理的最简单方法是使用以下设置:

JAVA_OPTS=-Djava.net.useSystemProxies=true

或创建包含以下内容的.jvmopts文件:

-Djava.net.useSystemProxies=true

如果您尚未设置系统代理信息,则需要更明确:

JAVA_OPTS=-Dhttp.proxyHost=my.proxyhost.com -Dhttp.proxyPort=80 -Dhttps.proxyHost=my.proxyhost.com -Dhttps.proxyPort=443

或,在.jvmopts中:

-Dhttp.proxyHost=my.proxyhost.com
-Dhttp.proxyPort=80
-Dhttps.proxyHost=my.proxyhost.com
-Dhttps.proxyPort=443

另请注意,如果您的代理使用 SOCKS 而不是 HTTP ,则相关设置将为:

JAVA_OPTS=-DsocksProxyHost=my.proxyhost.com -DsocksProxyPort=8080

或,在.jvmopts中:

-DsocksProxyHost=my.proxyhost.com
-DsocksProxyPort=8080

显然,您需要将这些主机地址和端口号替换为代理的地址和端口号。 (如果您的域向代理服务器验证您的身份,则不需要指定用户名和密码设置。)

这应确保 SBT 在命令行中运行,以及从 IntelliJ 中执行 SBT 任务的场合(作为< em>运行配置)。

但是, IntelliJ 也有自己的代理设置,它在内部运行 SBT 时使用。你也需要配置它。您可以通过文件/设置... 菜单选项访问 IntelliJ 代理设置,然后查看外观&amp;行为/系统设置/ HTTP代理(或在设置搜索框中键入'proxy'):

enter image description here

让我知道你是怎么过的......

答案 1 :(得分:-1)

对我来说,代理设置(无论是否在Intellij,SBT.conf或环境变量中设置)都不起作用。

解决这个问题的几个考虑因素(至少对我来说):

- 如果你使用SBT 0.13.16(不比那更新)

- 设置使用自动导入

然后,没有&#34; FAILED DOWNLOADS&#34;消息出现。

答案 2 :(得分:-1)

不幸的是,以上选项对我来说都不起作用。更令人沮丧的是,Maven在同一个公司代理中也可以正常工作。我只是将具有URL,端口,用户名和密码的凭据添加到settings.xml中。

我们有一个经过身份验证的代理。我得到的错误是java.io.Expection:无法针对代理进行身份验证。