maven中设置代理服务器

来源:互联网 发布:mycard点卡淘宝 编辑:程序博客网 时间:2024/06/11 13:29

打开%m2_home%/bin/settings.xml,增加如下一段:

<proxies>
    <!-- 使用代理上网 -->
    <proxy>
        <id>optional</id>
        <active>true</active>
        <protocol>http</protocol>
        <username></username>
        <password></password>
        <host>192.168.1.1</host>
        <port>8081</port>
        <nonProxyHosts>localhost|127.0.0.1</nonProxyHosts>
    </proxy>
</proxies>
host、port、username、password不用说,nonProxyHosts就是例外地址。
 

如果bin下面没有settings.xml,手工新建一个,完整的setting.xml如下:

<settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                                http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <localRepository />
    <interactiveMode />
    <usePluginRegistry />
    <offline />
    <pluginGroups />
    <servers />
    <proxies>
        <!-- 使用代理上网 -->
        <proxy>
            <id>optional</id>
            <active>true</active>
            <protocol>http</protocol>
            <username></username>
            <password></password>
            <host>192.168.1.1</host>
            <port>8081</port>
            <nonProxyHosts>localhost|127.0.0.1</nonProxyHosts>
        </proxy>
    </proxies>
    <profiles />
    <activeProfiles />
</settings>

 

完成后保存,再往c:\document and setting\\.m2\下面复制一份即可。


原创粉丝点击