【问题标题】:How to use sbt from behind proxy - in windows 7?如何在代理后面使用 sbt - 在 Windows 7 中?
【发布时间】:2015-01-23 12:20:12
【问题描述】:

我正在尝试在 Windows 7 上运行 SBT。为此,我按照类似线程“How to use sbt from behind proxy?”中的步骤操作。

我有以下相关的“系统变量”:

变量名: JAVA_OPTS 变量值: -Dhttp.proxySet=true -Dhttp.proxyHost=192.168.0.150 -Dhttp.proxyPort=8080

变量名: SBT_OPTS 变量值: -Dhttp.proxySet=true -Dhttp.proxyHost=192.168.0.150 -Dhttp.proxyPort=8080

变量名: SBT_HOME 变量值: C:\Program Files (x86)\sbt\

我也改了C:\Program Files (x86)\sbt\conf\sbtconfig.txt的内容

***** sbtconfig.txt 开始 *****

*将 java args 设置为高

-Xmx512M

-XX:MaxPermSize=256m

-XX:ReservedCodeCacheSize=128m

*设置额外的 SBT 选项

-Dsbt.log.format=true

*设置代理

-Dhttp.proxySet=true

-Dhttp.proxyHost=192.168.0.150

-Dhttp.proxyPort=8080

***** sbtconfig.txt END *****

运行cmd.exe 我输入sbt。 cmd回显

获取 org.fusesource.jansi jansi 1.11 ....

大约 1 分钟后,我收到很多警告和错误,例如:

[...]

:::: ERRORS 服务器访问错误:连接超时:连接 url=https://repo.typesafe.com/typesafe/ivy-releases/org.fusesource.jansi/jansi/1.11.ivys/ivy.xml

[...]

这与没有代理设置的情况完全相同。当我在浏览器中输入上述地址时,我也很惊讶,我得到的只是:

***** 浏览器显示开始 *****

{

“错误”:[ {

“状态”:404,

“消息”:“找不到文件。”

}]

}

***** 浏览器显示 END *****

我如何确定 SBT 是否正在尝试使用代理,或者是否存在其他问题?

【问题讨论】:

    标签: windows-7 sbt http-proxy


    【解决方案1】:

    感谢 Paweł 的回答。

    这是我发现的:

    -Dhttp.proxySet=true”没有任何作用(至少对我来说)

    设置的优先顺序如下:

    SBT_OPTS 覆盖 JAVA_OPTS 覆盖 %SBT_HOME%conf\sbtconfig.txt

    解决方案是设置环境变量之一

    JAVA_OPTS=-Dhttp.proxyHost=192.168.0.150 -Dhttp.proxyPort=8080 -Dhttps.proxyHost=192.168.0.150 -Dhttps.proxyPort=8080 -Dhttp.nonProxyHosts=localhost
    

    SBT_OPTS=-Dhttp.proxyHost=192.168.0.150 -Dhttp.proxyPort=8080 -Dhttps.proxyHost=192.168.0.150 -Dhttps.proxyPort=8080 -Dhttp.nonProxyHosts=localhost
    

    或者编辑 %SBT_HOME%conf\sbtconfig.txt 文件:

    ***** sbtconfig.txt BEGINNING (hashtags in this file have been replaced by stars) *****
    
    *Set the java args to high
    
    -Xmx512M
    
    *-XX:MaxPermSize=256m
    
    -XX:ReservedCodeCacheSize=128m
    
    *Set the extra SBT options
    
    -Dsbt.log.format=true
    
    *Proxy settings
    
    -Dhttp.proxyHost=192.168.0.150 
    
    -Dhttp.proxyPort=8080
    
    -Dhttps.proxyHost=192.168.0.150 
    
    -Dhttps.proxyPort=8080
    
    ***** sbtconfig.txt END *****
    

    【讨论】:

      【解决方案2】:

      让我们看看你的错误:

      :::: ERRORS Server access Error: Connection timed out: connect url=https://repo.typesafe.com/typesafe/ivy-releases/org.fusesource.jansi/jansi/1.11.ivys/ivy.xml
      

      Sbt 正在尝试使用 https,但您没有为它配置代理。 尝试设置 https 代理变量:

      • https.proxyHost
      • https.proxyPort

      我猜你可以尝试与 http 代理相同的值。

      【讨论】:

        【解决方案3】:

        转到您的 SBT 文件夹并使用以下命令

        set SBT_OPTS=-Dhttp.proxyHost=10.10.10.154 -Dhttp.proxyPort=8080 -Dhttps.proxyHost=10.10.10.154 -Dhttps.proxyPort=8080 -Dhttp.nonProxyHosts=localhost <Enter your IP settings >
        

        然后

        sbt.bat
        

        【讨论】:

        • 谢谢!我直接在 /usr/share/sbt/conf/ 中的 sbtopt 文件中添加了代理设置
        【解决方案4】:

        sbt 使用 Gigahorse 和 OkHttp 进行并行下载。您可以尝试通过传递 -Dsbt.gigahorse=false 将其关闭。

        您可以尝试的另一件事是关闭 https,并通过传递 -Dsbt.repository.secure=false 来使用 http

        参考:https://github.com/sbt/sbt/issues/4307

        【讨论】:

          猜你喜欢
          • 2012-11-28
          • 2023-03-31
          • 1970-01-01
          • 2011-07-03
          • 2018-08-01
          • 2011-01-17
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多