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?
Advertisement
Answer
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.