Java Intellij 社区无法为 Maven 使用 http 代理
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1784132/
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
Intellij Community can't use http proxy for Maven
提问by MikeHoss
I have Intellij IDEA Community installed on a Linux box that needs to use an authenticated proxy to get to the Internet. I have a system-wide proxy on the box that works, and I have the proxy configured in ~/.m2/settings.xml. Maven correctly uses the proxy when I run try it from the command-line.
我在需要使用经过身份验证的代理才能访问 Internet 的 Linux 机器上安装了 Intellij IDEA 社区。我在盒子上有一个系统范围的代理,我在 ~/.m2/settings.xml 中配置了代理。当我从命令行运行时,Maven 正确使用代理。
I have the same proxy configured within Intellij and it gives me the plugins listing correctly. But when I try to sync with the Maven repository withing Intellij I keep getting this:
我在 Intellij 中配置了相同的代理,它为我提供了正确列出的插件。但是当我尝试使用 Intellij 与 Maven 存储库同步时,我不断收到以下信息:
[WARNING] Unable to get resource 'org.codehaus.mojo:hibernate3-maven-plugin:pom:2.2'
from repository restlet (http://maven.restlet.org): Authorization failed: Not
authorized by proxy.
I went to Settings->Maven and put in the proxy info as properties and that didn't work. I can see by looking at those settings that Intellij is reading my ~./m2/settings.xml fine because it knows where my local repo is (it's in a non-standard place).
我去了 Settings->Maven 并将代理信息作为属性输入,但没有用。我可以通过查看 Intellij 正在读取我的 ~./m2/settings.xml 的那些设置看到,因为它知道我的本地存储库在哪里(它位于非标准位置)。
Anyone know how I can get this working?
有谁知道我怎样才能让它工作?
采纳答案by MikeHoss
I commented out the proxy config in my ~/.m2/settings.xml file, let the Intellij Proxy info alone, and then supplied the properties in Setting->Maven. Not sure why that worked (nor why the settings.xml wasn't working right) but it's working now.
我在 ~/.m2/settings.xml 文件中注释掉了代理配置,让 Intellij 代理信息单独存在,然后在 Setting->Maven 中提供属性。不知道为什么会这样(也不知道为什么 settings.xml 不能正常工作)但它现在正在工作。
回答by jitter
Can you try either removing the proxy setting in settings.xmlor the setting in IntelliJ itself.
您可以尝试删除settings.xml 中的代理设置或 IntelliJ 本身中的设置。
And then try to sync with the maven repo from within Intellij.
然后尝试从 Intellij 中与 Maven 存储库同步。
回答by Paul W
I Have found similar issues with the Maven 2.2 integration in intellij 9. I am using 9.0.1
我在 Intellij 9 中发现了与 Maven 2.2 集成类似的问题。我使用的是 9.0.1
I use intellij behind a corporate firewall/proxy. If I point Intellij's maven conf to use external Maven and maven conf that has the proxy settings inside, intellij fails to download artifacts from any remote repositories.
我在公司防火墙/代理后面使用 Intellij。如果我将 Intellij 的 maven conf 指向使用内部具有代理设置的外部 Maven 和 maven conf,intellij 无法从任何远程存储库下载工件。
Had no problems with intellij-8, this only started after the upgrade. The Maven conf has not changed either.
intellij-8 没有问题,这只是在升级后才开始。Maven conf 也没有改变。
I have to do a Maven build from command line to get any new dependent artifacts into my local repo then use intellij-9.
我必须从命令行进行 Maven 构建,才能将任何新的依赖工件放入我的本地存储库,然后使用 intellij-9。
The Maven 2.2 integration has issues behind proxy servers.
Maven 2.2 集成在代理服务器背后存在问题。
回答by James Macmillan
I have had the same issue. However, my proxy settings were stored under the environment variable *M2_OPTS*.
我有同样的问题。但是,我的代理设置存储在环境变量 *M2_OPTS* 下。
As per the above posts, deleting the environment variables stopped IDEA from hanging.
根据上面的帖子,删除环境变量可以阻止 IDEA 挂起。
This is under Windows 7, using IntelliJ IDEA CE 12.3
这是在 Windows 7 下,使用 IntelliJ IDEA CE 12.3
If anyone notices an open bugfix for this please respond with a link.
如果有人注意到一个开放的错误修正,请回复一个链接。
回答by DrBug
Navigate to
Maven > Importing
1. inside the IntelliJ IDEA Settings (which is found underFile > Settings
).The second last option in
Maven > Importing
is a field named "VM options for importer". Append the following to whatever already exists there:-DproxySet=true -DproxyHost=myproxy.com -DproxyPort=3128
Here, replace
myproxy.com
with your proxy server, (e.g. http://myproxyserver.com). Replace3128
with your proxy port (e.g. 8080).Do the same under
Maven > Runner
1Apply and close the settings window.
导航到
Maven > Importing
1。IntelliJ IDEA 设置(位于 下File > Settings
)。中的倒数第二个选项
Maven > Importing
是名为“导入程序的 VM 选项”的字段。将以下内容附加到那里已经存在的内容中:-DproxySet=true -DproxyHost=myproxy.com -DproxyPort=3128
在这里,替换
myproxy.com
为您的代理服务器,(例如 http://myproxyserver.com)。替换3128
为您的代理端口(例如 8080)。在1下做同样的事情
Maven > Runner
应用并关闭设置窗口。
It should work now.
它现在应该可以工作了。
1This may be nested under Build, Execution, Deployment > Build Tools >
, depending on the version of IntelliJ you're using.
1这可能嵌套在 下Build, Execution, Deployment > Build Tools >
,具体取决于您使用的 IntelliJ 版本。
回答by user3298801
I had the same problem running maven inside IntelliJ whilst behind an NTLM proxy. The working solution was as follows:
我在 IntelliJ 中运行 maven 时遇到了同样的问题,而在 NTLM 代理后面。工作解决方案如下:
- Download and install CNTLM. Excellent post here on how to do this https://stackoverflow.com/a/23962313/3298801
- Set and test your local proxy settings in IntelliJ via Settings >> System Settings >> HTTP Proxy.
- In Intellij set the maven runner. Within Settings >> Maven >> runner set VM options to:
-DproxySet=true -DproxyHost=localhost -DproxyPort=3132
- Restart Intellij
- Note within ~/.m2/settings.xml I also added my proxy config as:
- 下载并安装 CNTLM。关于如何做到这一点的优秀帖子https://stackoverflow.com/a/23962313/3298801
- 通过设置 >> 系统设置 >> HTTP 代理在 IntelliJ 中设置和测试您的本地代理设置。
- 在 Intellij 中设置 maven runner。在 Settings >> Maven >> runner 中将 VM 选项设置为:
-DproxySet=true -DproxyHost=localhost -DproxyPort=3132
- 重启 Intellij
- 注意 ~/.m2/settings.xml 我还添加了我的代理配置:
<proxies>
<proxy>
<active>true</active>
<protocol>https</protocol>
<host>localhost</host>
<port>3132</port>
</proxy>
</proxies>
回答by Rail
I meet the same problem.By ShadowsocksR,I can visit some websites that i can't visit without ShadowsocksR. I use Intellij , the error is "Connection timed out: connect -> [Help 1]".At last, I also added my proxy config as:
我遇到了同样的问题。通过ShadowsocksR,我可以访问一些没有ShadowsocksR就无法访问的网站。我使用 Intellij ,错误是“连接超时:连接-> [帮助 1]”。最后,我还添加了我的代理配置:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<proxies>
<proxy>
<id>example-proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>localhost</host>
<port>1080</port>
<username>***.***.**.***:****</username>
<password>*******</password>
<nonProxyHosts>www.baidu.com|*.example.com</nonProxyHosts>
</proxy>
</proxies>
</settings>
My computer environment is win10. http://maven.apache.org/guides/mini/guide-proxies.html
我的电脑环境是win10。http://maven.apache.org/guides/mini/guide-proxies.html
回答by Simon
A little update for memo. I don't have a standalone maven installed, so finally I fixed this by modifying the maven plugin settings. settings.xml is located at :
备忘录的小更新。我没有安装独立的 maven,所以最后我通过修改 maven 插件设置来解决这个问题。settings.xml 位于:
IntelliJ IDEA Community Edition 2017.3.4\plugins\maven\lib\maven3\conf\settings.xml
IntelliJ IDEA 社区版 2017.3.4\plugins\maven\lib\maven3\conf\settings.xml
You can find proxy settings and change it as mentioned above.
您可以找到代理设置并按上面所述进行更改。