idea maven 设置代理

maven 编译时设置代理

这个 settings.xml 文件放在 C:\Users\username.m2 路径下

bash 复制代码
<?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>myproxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>user</username>  <!-- Put your username here -->
      <password>pass</password>  <!-- Put your password here -->
      <host>123.45.6.78</host>   <!-- Put the IP address of your proxy server here -->
      <port>80</port>            <!-- Put your proxy server's port number here -->
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts> <!-- Do not use this setting unless you know what you're doing. -->
    </proxy>    
  </proxies> 
</settings>

参考
https://stackoverflow.com/questions/15334394/could-not-transfer-artifact-org-apache-maven-pluginsmaven-surefire-pluginpom2

导航至Maven > Importing。在IntelliJ IDEA设置中(位于File > Settings下)。

Maven > Importing中的倒数第二个选项是名为"导入程序的VM选项"的字段。将以下内容附加到已存在的内容中:

-DproxySet=true -DproxyHost=127.0.0.1 -DproxyPort=1081

处,将127.0.0.1替换为您的代理服务器

在Maven > Runner

下执行相同操作