Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force m2e to use http instead of https

Tags:

eclipse

maven

m2e

My eclipse installation always uses the https protocol to download repository structures. The problem is that my cooperate proxy wont let me use https on this url. How to force m2e to use http?

I tried with different external maven installations for m2e but no luck. It only works if i use the external maven from CLI, which uses http.

like image 469
calaedo Avatar asked Aug 17 '15 12:08

calaedo


People also ask

How do I change from http to https in Maven?

The solution is very easy, you just need to replace the urls to maven central repository (and maybe other main repositories) to https instead of http. That's all!!! In case, you have never defined the repositories url and you are using the default values, you just need to add the new repositories with https.

How do I access Maven central repository?

Where is the Maven Central repository? Maven Central can be accessed from https://repo.maven.apache.org/maven2/.


2 Answers

I had a similar problem and I fixed that adding the code below to my pom.xml:

<repositories>
    <repository>
        <id>central-repo</id>
        <name>Central Repository</name>
        <url>http://repo1.maven.org/maven2</url>
    </repository>
</repositories>
like image 132
Marcel Avatar answered Oct 04 '22 02:10

Marcel


I'd recommend using an external Maven installation anyway, don't rely on the built-in version. In your Maven directory, find the <maven>/conf/settings.xml file. There you can edit your 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>

Also, you should update your Maven settings in Eclipse (Maven -> User Settings):

Maven User Settings

like image 32
user1438038 Avatar answered Oct 04 '22 03:10

user1438038