'Could not transfer artifacts from/to central maven repo when using Spring Framework Cloud
I am trying to create a maven project using Spring Framework Cloud. I defined pom.xml file as below
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Brixton.RELEASE</version>
</parent>
<properties>
<!-- Stand-alone RESTFul application for testing only -->
<start-class>io.pivotal.microservices.services.Main</start-class>
</properties>
<dependencies>
<dependency>
<!-- Setup Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<!-- Setup Spring MVC & REST, use Embedded Tomcat -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<!-- Setup Spring Data common components -->
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
<dependency>
<!-- Testing starter -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<!-- Setup Spring Data JPA Repository support -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<!-- In-memory database for testing/demos -->
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
<dependency>
<!-- Spring Cloud starter -->
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>
<dependency>
<!-- Eureka service registration -->
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
</dependencies>
When trying to build maven getting error for all dependencies as
Could not transfer artifacts from/to central (https://repo.maven.apache.org/maven2)
Multiple annotations found at this line: - Failure to transfer org.springframework:spring-orm:jar:4.2.6.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:spring-orm:jar:4.2.6.RELEASE from/to central
(https://repo.maven.apache.org/maven2): The operation was cancelled. org.eclipse.aether.transfer.ArtifactTransferException: Failure to transfer org.springframework:spring-orm:jar: 4.2.6.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:spring-orm:jar:4.2.6.RELEASE from/to central (https://repo.maven.apache.org/maven2): The operation was cancelled. at
org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:238) at
org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:206) at
org.eclipse.aether.internal.impl.DefaultArtifactResolver.gatherDownloads(DefaultArtifactResolver.java:585) at
org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:503) at
org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421) at
org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246) at
org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:367) at
When I go to the location, I can clearly see the Jar files are present in that location. Is there something else I need to add to my pom.xml?
Solution 1:[1]
I tried the same pom.xml inEclipse IDE and surprisingly it worked there as it is.
To make it work on STS, I added following properties
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<start-class>io.pivotal.microservices.services.Main</start-class>
<spring-cloud.version>Brixton.RELEASE</spring-cloud.version>
</properties>
Refer Unable to download/import package org.springframework.cloud.config.server.EnableConfigServer
This worked for me, though I am still curious about the difference.
Solution 2:[2]
Try force refreshing your dependencies. Specifying -U
does that
mvn clean install -U
Edit:
You can purge your local release dependencies and to the normal mvn clean install
afterwards:
mvn dependency:purge-local-repository
There is not way to force the release dependencies to be pulled, the -U
only works with snapshot dependencies
Solution 3:[3]
I had the same error on my project and this is what worked for me.
First of all, go to your pom.xml
and find your spring-parent version. Then
go to https://repo.maven.apache.org/maven2/springframework/spring-parent and check if your same springframework version exists, if not change your springframework version to an existing one.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Poorvi Nigotiya |
Solution 2 | |
Solution 3 | Deusy94 |