关于java:Maven插件未使用Eclipse的代理设置

Maven plugin not using Eclipse's proxy settings

我正在使用基于Eclipse 3.7的springsource工具套件2.7.2。 现在Maven插件随Eclipse一起提供,这非常棒,即使在早期版本的Eclipse中也出现了此问题。

所以这是我的问题:

我已经在settings.xml文件中设置了代理信息,并且在命令行上Maven可以正常工作。 我还在Eclipse配置本身中设置了相同的代理详细信息,并且我知道它是正确的,并且更新可以使用它,而不是不可以。

当然,我的Eclipse安装中的Maven插件设置为使用正确的settings.xml文件。

但是,eclipse中的maven只是不使用这两个位置中的任何一个的代理设置,每次我更改pom文件时,这都很烦人。
有人对此问题有解决方案吗?

settings.xml

这是我的settings.xml文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?xml version="1.0" encoding="UTF-8"?>
  <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">

  <profiles>
    <profile>
      <id>general</id>
      <repositories>
        <repository>
          <snapshots><enabled>false</enabled></snapshots>
          <id>ibiblio</id>
          <name>Maven ibiblio</name>
          <url>http://www.ibiblio.org/maven2</url>
        </repository>

        <repository>
          <snapshots><enabled>true</enabled></snapshots>
          <id>ibiblio2</id>
          <name>Maven ibiblio2</name>
          <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
        </repository>

        <repository>
          <snapshots><enabled>true</enabled></snapshots>
          <id>maven</id>
          <name>Maven sunsite</name>
          <url>http://repo1.maven.org/maven2/</url>
        </repository>

        <repository>
          <snapshots><enabled>true</enabled></snapshots>
          <id>jboss</id>
          <name>Maven jboss</name>
          <url>http://repository.jboss.org/maven2/</url>
        </repository>
      </repositories>
    </profile>
  </profiles>

 
    general</activeProfile>
  </activeProfiles>

  <proxies>
    <proxy>
      <id>proxy</id>
      true</active>
      <protocol>http</protocol>
      <host>myproxyserver</host>
      <port>80</port>
      <username>myusername</username>
      <password>mypassword</password>
    </proxy>
  </proxies>
</settings>


Maven插件使用可以在其中设置配置的设置文件。 Eclipse的Window|Preferences|Maven|User Settings中提供了其路径。 如果该文件不存在,请创建它并放入以下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<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"
>
  <localRepository/>
  <interactiveMode/>
  <usePluginRegistry/>
  <offline/>
  <pluginGroups/>
  <servers/>
  <mirrors/>
  <proxies>
    <proxy>
      <id>myproxy</id>
      true</active>
      <protocol>http</protocol>
      <host>192.168.1.100</host>
      <port>6666</port>
      <username></username>
      <password></password>
      <nonProxyHosts>localhost|127.0.0.1</nonProxyHosts>
    </proxy>
  </proxies>
  <profiles/>
 
</settings>

编辑文件后,只需单击Update Settings按钮即可完成。 我刚刚做到了,它就起作用了:)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">

     <proxies>
       <proxy>
          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>

窗口>首选项> Maven>用户设置

enter image description here


默认情况下,Eclipse不了解您的外部Maven安装,而是使用嵌入式安装。 因此,为了使Eclipse使用全局设置,您需要在菜单设置→Maven→安装中对其进行设置。