1

I am new to the spring boot framework and I'm trying to import the Maven libraries, but I keep getting an error with my pom.xml. Please Help!

Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:2.0.4.RELEASE from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.0.4.RELEASE from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org

Dependency 'org.springframework.boot:spring-boot-starter-web:' not found less... (Ctrl+F1) Inspection info: Inspects a Maven model for resolution problems.

Plugin 'org.springframework.boot:spring-boot-maven-plugin:2.0.4.RELEASE' not found less... (Ctrl+F1) Inspection info: Inspects a Maven model for resolution problems.

Here is my pom.xml below:

<?xml version="1.0" encoding="UTF-8"?>
<project 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/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

<groupId>com.cierra</groupId>
<artifactId>spring-boot</artifactId>
<version>0.0.1-SNAPSHOT</version>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.4.RELEASE</version>
</parent>


<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

<properties>
    <java.version>1.8</java.version>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.0.4.RELEASE</version>
        </plugin>
    </plugins>
</build>


</project>
C. Lewis
  • 145
  • 1
  • 6
  • 17
  • The first set-to debugging these issues is to ensure that your project builds from a command line. Therefore please try `mvn clean install -U` from a command/terminal window and report the results. The "-U" ensures that you don't get cached errors. – Steve C Oct 27 '18 at 02:22
  • @SteveC C When I run the report I get the following errors: [ERROR] Some problems were encountered while processing the POMs: [FATAL] Non-resolvable parent POM for com.cierra:spring-boot:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.0.4.RELEASE from/to spring-snapshots (https://repo.spring.io/snapshot): repo.spring.io and 'parent.relativePath' points at no local POM @ line 14, column 13 – C. Lewis Oct 30 '18 at 19:40
  • Spring Boot is currently at 2.1.4.RELEASE. I'd wonder why you're sticking with the older version. If this is a new project, why not be current? – duffymo May 28 '19 at 18:28

3 Answers3

2

This maybe due to the reason that it is not able to connect and transfer dependencies specified in pom.xml file. The details where it is trying to connect must be mentioned in your settings.xml under .m2 folder

Try adding the pluginRepositories in your pom.xml file:

<pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <url>http://repo.spring.io/libs-snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

try adding following repository elements inside repositories element in your pom.xml

<repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>

If this set well, change your updatePolicy settings.

 <repository>
      <id>myRepo</id>
      <name>My Repository</name>
      <releases>
        <enabled>false</enabled>
        <updatePolicy>always</updatePolicy>
        <checksumPolicy>warn</checksumPolicy>
      </releases>
     </repository>

Refer question.

Nitin1706
  • 621
  • 1
  • 11
  • 21
  • I added these to my pom.xml, but no luck. I did look into my .m2 folder and notice I don't have a settings.xml, that may be the problem. Do you know how this is configured? – C. Lewis Oct 26 '18 at 18:37
  • maybe in your case, it is due to the reason that it is not able to find the local repo. For missing settings.xml file, refer this: https://stackoverflow.com/questions/5308079/why-maven-settings-xml-file-is-not-there – Nitin1706 Oct 26 '18 at 18:44
  • check your updatePolicy: https://stackoverflow.com/questions/4856307/when-maven-says-resolution-will-not-be-reattempted-until-the-update-interval-of – Nitin1706 Oct 26 '18 at 18:59
1

The problem was I was behind a proxy that was blocking my pom.xml from running properly. After using a VPN to run the application, it works fine now.

C. Lewis
  • 145
  • 1
  • 6
  • 17
0

Change Your Maven Version Ad Check Again.

Install Maven and Then Go to File/setting/build,execution,.../build Tools/maven And Change Maven Home Directory to Your Install Maven Directory

U13-Forward
  • 69,221
  • 14
  • 89
  • 114
hani
  • 49
  • 1
  • 7