scala 我在哪里可以在 Intellij IDEA 中为 SBT 设置代理?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30860940/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 07:15:45  来源:igfitidea点击:

Where can I set proxy for SBT in Intellij IDEA?

scalaintellij-ideaproxysbt

提问by Nan Xiao

I am using Intellij IDEA 14.1.3edition and have installed Scalaplugin. When creating SBTproject, it reports the following error:

我正在使用Intellij IDEA 14.1.3版本并安装了Scala插件。创建SBT项目时,报如下错误:

Error:Error while importing SBT project:
...
        ::::::::::::::::::::::::::::::::::::::::::::::

        :: org.fusesource.jansi#jansi;1.11: not found

        ::::::::::::::::::::::::::::::::::::::::::::::


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

    Server access Error: Connection timed out: connect url=http://repo1.maven.org/maven2/org/fusesource/jansi/jansi/1.11/jansi-1.11.pom

    Server access Error: Connection timed out: connect url=http://repo1.maven.org/maven2/org/fusesource/jansi/jansi/1.11/jansi-1.11.jar


:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
unresolved dependency: org.fusesource.jansi#jansi;1.11: not found
Error during sbt execution: Error retrieving required libraries
  (see C:\Users\xiaona\.sbt\boot\update.log for complete log)
Error: Could not retrieve jansi 1.11

See complete log in C:\Users\xiaona\.IdeaIC14\system\log\sbt.last.log

After referring this post, I see the root cause should be that I use proxy to connect internet.

参考这篇文章后,我看到根本原因应该是我使用代理连接互联网。

But in SBTsetting screen:
enter image description here

但是在SBT设置屏幕中:
在此处输入图片说明

I can't find a place to set proxy. Where can I set proxy for SBTin Intellij IDEA?

我找不到设置代理的地方。在哪里可以设置SBTin 的代理Intellij IDEA

回答by Sergii Lagutin

Add -Dhttp.proxyHost=<proxy_server> -Dhttp.proxyPort=<proxy_port>to VM parameters

添加-Dhttp.proxyHost=<proxy_server> -Dhttp.proxyPort=<proxy_port>到 VM 参数

Read documentationfor more info

阅读文档了解更多信息

回答by Boern

Basically there are three ways of setting the proxy. Each of them seems to affect a different part of the IDE.

基本上有三种设置代理的方法。它们中的每一个似乎都会影响 IDE 的不同部分。

For all following three methods I recommend setting both, httpand https, since most connections to repos are established using httpsnowadays:

对于以下所有三种方法,我建议同时设置httphttps,因为大多数与存储库的连接都是使用https现在建立的:

-Dhttp.proxyHost=yourProxyAdress 
-Dhttp.proxyPort=yourPort 
-Dhttp.proxyUser=yourUsername 
-Dhttp.proxyPassword=yourPassword 
-Dhttps.proxyHost=yourProxyAdress
-Dhttps.proxyPort=yourPort 
-Dhttps.proxyUser=yourUsername 
-Dhttps.proxyPassword=yourPassword 

1. Build Tools

1. 构建工具

Setting the proxy under "Build, Execution, Deployment" > "Build Tools" > "SBT" > "VM parameters" affects the SBT process that is executed after editing the build.sbtfile and refreshing the latter. Also, this is used for indexing (and therefore auto completion). This setting will also affect the download of SBT itself in the version you selected during project setup.

在“构建、执行、部署”>“构建工具”>“SBT”>“VM 参数”下设置代理会影响编辑build.sbt文件并刷新后者后执行的SBT 进程。此外,这用于索引(因此自动完成)。此设置还将影响您在项目设置期间选择的版本中的 SBT 本身的下载。

2. Other Settings

2. 其他设置

Aditionally, I used the setting under "Other Settings" > "SBT" > "VM parameters"

另外,我使用了“其他设置”>“SBT”>“VM 参数”下的设置

Setting VM parameters

Setting VM parameters

3. Setting the proxy globally

3.全局设置代理

Another way would be to set the proxy settings globally with your JAVA_OPTSas described here.

另一种方法是使用您JAVA_OPTS此处描述的全局设置代理设置。

回答by Wisarut Yeamsup

Add parameter VM

添加参数VM

-Dhttps.proxyHost=hostName 
-Dhttps.proxyPort=portUse 
-Dhttps.proxyUser=proxyName 
-Dhttps.proxyPassword=proxyPaword

It work for me

它对我有用

回答by Atais

In my situation I have tried all above solutions, but they did not work.

在我的情况下,我已经尝试了上述所有解决方案,但没有奏效。

In the end I have configured HTTP proxy for the whole IntellJ, and that have resolved my issues.

最后,我为整个 配置了 HTTP 代理IntellJ,这解决了我的问题。

Settings > Appearance & Behaviour > System Settings > Http Proxy

settings

settings

回答by Javier Morant

If you are running a sbt-based scala project you may need to add the proxy in the run configuration of the project: Run -> Edit configurations...->->VM parameters

如果你正在运行一个基于 sbt 的 scala 项目,你可能需要在项目的运行配置中添加代理:运行 -> 编辑配置...->->VM 参数

enter image description here

enter image description here

回答by Deej

I was seeing this same error message and tried all the suggestions mentioned in multiple (related) threads. I was able to finally resolve the problem by setting up the HTTP Proxy directly in IntelliJ. Here's what my settings look like (Note: specify your network username and password in the corresponding boxes):-

我看到了同样的错误消息,并尝试了多个(相关)线程中提到的所有建议。通过直接在 IntelliJ 中设置 HTTP 代理,我最终解决了这个问题。这是我的设置的样子(注意:在相应的框中指定您的网络用户名和密码):-

enter image description here

enter image description here