强制m2e使用http而不是https

时间:2015-08-17 12:19:36

标签: eclipse maven m2e

我的eclipse安装总是使用https协议下载存储库结构。问题是我的合作代理不会让我在这个网址上使用https。如何强制m2e使用http?

我尝试使用m2e的不同外部maven安装,但没有运气。 它只适用于我使用CLI的外部maven,它使用http。

2 个答案:

答案 0 :(得分:13)

我建议使用外部Maven安装,不要依赖内置版本。在Maven目录中,找到<maven>/conf/settings.xml文件。在那里,您可以修改proxy settings

<settings>
  <proxies>
   <proxy>
      <id>example-proxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.example.com</host>
      <port>8080</port>
      <username>proxyuser</username>
      <password>somepassword</password>
      <nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
    </proxy>
  </proxies>

  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>insecurecentral</activeProfile>
  </activeProfiles>
  <profiles>
    <profile>
      <id>insecurecentral</id>
      <!--Override the repository (and pluginRepository) "central" from the Maven Super POM -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://repo1.maven.org/maven2</url>
          <releases>
            <enabled>true</enabled>
          </releases>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://repo1.maven.org/maven2</url>
          <releases>
            <enabled>true</enabled>
          </releases>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
</settings>

此外,您应该在Eclipse中更新Maven设置(Maven - &gt;用户设置):

Maven User Settings

答案 1 :(得分:6)

我遇到了类似的问题,我修复了将下面的代码添加到 pom.xml

<repositories>
    <repository>
        <id>central-repo</id>
        <name>Central Repository</name>
        <url>http://repo1.maven.org/maven2</url>
    </repository>
</repositories>
相关问题