37
votes

I am trying to build my project but I get this:

Non-resolvable parent POM: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:1.3.0.M3 from/to spring-snapshots (http://repo.spring.io/snapshot): repo.spring.io and 'parent.relativePath' points at no local POM @ line 16, column 10: Unknown host repo.spring.io -> [Help 2]

Here is how I specify the parent of my pom.xml:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.0.M3</version>
    <relativePath></relativePath>
</parent>

The is empty so that it forces maven to look for the parent in the remote repository. However, it says that repo.spring.io is an unknown host.

Here is how I define the repositories in my pom.xml:

<repositories>
    <repository>
        <id>spring-snapshots</id>
        <url>http://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>spring-milestones</id>
        <url>http://repo.spring.io/milestone</url>
    </repository>
</repositories>

<pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <url>http://repo.spring.io/snapshot</url>
    </pluginRepository>
    <pluginRepository>
        <id>spring-milestones</id>
        <url>http://repo.spring.io/milestone</url>
    </pluginRepository>
</pluginRepositories>

Any ideas?

14

14 Answers

35
votes

Obviously it's a problem with your internet connection. Check, if you can reach http://repo.spring.io with your browser. If yes, check if you need to configure a proxy server. If no, you should contact your internet provider.

Here is the documentation, how you configure a proxy server for Maven: https://maven.apache.org/guides/mini/guide-proxies.html

18
votes

For anyone stumbling upon this question, I'll post the solution to a similar problem (same error message except for the uknown host part).

Since January 15, 2020 maven central no longer supports HTTP, in favour of HTTPS. Consequently, spring repositories switched to HTTPS as well

The solution is therefore to change the urls from http://repo.spring.io/milestone to https://repo.spring.io/milestone.

7
votes

The issue is with your project which is not able to complete maven build. Steps to follow :

  1. Right Click Application and RunAs maven install.
  2. If you get any error while reaching the repos online try giving the proxies in settings.xml under your .m2 directory.Check this link for setting proxies for maven build.
  3. Once done , try doing a Update Project by Right Click Project , Maven->Update Maven Project and select codebase and do check the Force Update of Snapshot/Release check box.

This will update your maven build and will surely remove your errors with pom.xml

5
votes

Project->maven->Update Project->tick all checkboxes expect offline and error is solved soon.

4
votes

Rigth button on your project -> Maven -> Update

2
votes

In my case the problem was with the java version mismatch of pom.xml (java 1.8) and environment variables JAVA_HOME/JDK_HOME (java 1.7). After pointing environment variables JAVA_HOME & JDK_HOME to Java 1.8, the issue got resolved.

1
votes

If you're using docker-machine (docker on Windows or OSX).

Currently docker-machine has a bug that it loses internet connection if you switch between wifi networks or wifi and cable.

Make sure you restart your docker-machine

usually: docker-machine restart default

0
votes

As people already mentioned, it could be internet problems or proxy configuration.
I found this question when I was searching about the same problem. In my case, it was proxy configuration.
Answers posted here didn't solve my issue, because every link suggest a configuration that shows the username and passoword and I can't use it.
I was searching about it elsewere and I found a configuration to be made on settings.xml, I needed to make some changes. Here is the final code:

<profiles>
    <profile>
       <id>MavenRepository</id>
           <repositories>
            <repository>
                <id>central</id>
                <url>https://repo1.maven.org/maven2</url>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
                <releases>
                    <enabled>true</enabled>
                </releases>
            </repository>
        </repositories>
    </profile>
</profiles>

<activeProfiles>
    <activeProfile>MavenRepository</activeProfile>
</activeProfiles>

I hope be useful.

0
votes

If you are using docker service and you have switched to other network. You need to restart docker service.

service docker restart

This solved my problem in docker.

0
votes

Just a remind: I tried to work with idea and imported maven, and encountered the same problem, I have tried all the solutions and they didnt work. Finally, I found out it was because of the root access... I opened idea with administrator access and all things work just fine, hope you not as silly as i am...

0
votes

If all above stuffs not works. try this. If you are using IntelliJ. Check below setting: enter image description here

May be ~/.m2/settings.xml is restricting to connect to internet.

0
votes

Just right click on pom.xml > maven > update maven project > check the force update of Snapshots/Releases

-1
votes

Downgrade your version

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version><change this version></version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

Build and undo the version, Build. 2.1.6.RELEASE to 1.3.3.RELEASE Build Undo 1.3.3 to 2.1.6 Build (in my case problem solved) It helped us.

-1
votes

In the pom.xml (after loading effective pom.xml in eclipse), you may see it "http://repo.maven.apache.org/maven2" under central repository instead of "https://repo.maven.apache.org/maven2". Fix it