Maven 如何启用代理访问呢?
下文讲述,当你是采用http代理服务器的形式访问网络,那么你也必须在Maven中设置相应的代理,才能访问远端的Maven仓库,
实现思路: 找到Maven的配置文件中设置代理服务器即可修改步骤如下:
1.找到Maven的配置文件settings.xml
settings.xml文件在 {M2_HOME}/conf/settings.xml 如:本机Maven的安装位置 D:\javaSoft\java265.com\apache-maven 找到以下信息<!-- proxies | This is a list of proxies which can be used on this machine to connect to the network. | Unless otherwise specified (by system property or command-line switch), the first proxy | specification in this list marked as active will be used. |--> <proxies> <!-- proxy | Specification for one proxy, to be used in connecting to the network. | <proxy> <id>optional</id> <active>true</active> <protocol>http</protocol> <username>proxyuser</</username> <password>proxypass</password> <host>proxy.host.net</host> <port>80</port> <nonProxyHosts>local.net|some.host.com</nonProxyHosts> </proxy> --> </proxies>
2.取消proxies的注释信息,然后填写相应的代理服务器信息即可
<!-- proxies | This is a list of proxies which can be used on this machine to connect to the network. | Unless otherwise specified (by system property or command-line switch), the first proxy | specification in this list marked as active will be used. |--> <proxies> <proxy> <id>optional</id> <active>true</active> <protocol>http</protocol> <username>yiibai</username> <password>password</password> <host>proxy.java265.com</host> <port>9999</port> <nonproxyhosts>local.net|some.host.com</nonproxyhosts> </proxy> </proxies>
3.保存修改后的Settings.xml文件
重新修改settings.xml文件后,Maven就可通过代理访问互联网仓库版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。