我想分享我通过代理使用maven的经验。
你很可能会遇到异常和消息,如:
repository metadata for: 'org.apache.maven.plugins' could not be retrieved from repository: central due to an error: Error transferring file: Connection refused: connect
如何配置Maven以使用代理服务器?
发布于 2018-04-24 13:59:54
基本上,您需要确保全局设置([maven install]/conf/settings.xml
)或用户设置(${user.home}/.m2/settings.xml
)中的代理部分配置正确。最好在用户设置中执行此操作,以避免在公共位置以纯文本形式存储密码。
Maven 2.1引入了密码加密,但我没有仔细检查加密是否适用于代理设置以及存储库密码(不过看不出为什么它不会)。
有关信息,settings.xml中有一个注释掉的代理配置,以及如何修改它的说明。
设置应该如下所示:
<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>
<active>true</active>
<protocol>http</protocol>
<host>proxy.somewhere.com</host>
<port>8080</port>
<username>proxyuser</username>
<password>somepassword</password>
<nonProxyHosts>www.google.com|*.somewhere.com</nonProxyHosts>
</proxy>
</proxies>
[...]
</settings>
发布于 2018-04-24 15:07:36
建立到某个服务器的SSH隧道:
ssh -D $PORT $USER@$SERVER
Linux(bash):
export MAVEN_OPTS="-DsocksProxyHost=127.0.0.1 -DsocksProxyPort=$PORT"
视窗:
set MAVEN_OPTS="-DsocksProxyHost=127.0.0.1 -DsocksProxyPort=$PORT"
https://stackoverflow.com/questions/-100008245
复制相似问题