I am trying to create a maven project using Spring Framework Cloud. I defined pom.xml file as below
我正在尝试使用Spring Framework Cloud创建一个maven项目。我定义了pom.xml文件,如下所示
<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
当尝试构建maven时,所有依赖项都会出错
Could not transfer artifacts from/to central (https://repo.maven.apache.org/maven2)
无法将工件从/向*传输(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在此行找到多个注释: - 无法传输org.springframework:spring-orm:jar:4.2.6.RELEASE来自https://repo.maven.apache.org/maven2缓存在本地存储库中,解决方案不会重新尝试,直到中心的更新间隔已经过去或强制更新为止。原始错误:无法传输工件org.springframework:spring-orm:jar:4.2.6.RELEASE from / to central(https://repo.maven.apache.org/maven2):操作已取消。 org.eclipse.aether.transfer.ArtifactTransferException:故障转移org.springframework:弹簧ORM:罐子:从https://repo.maven.apache.org/maven2 4.2.6.RELEASE本地资源库中,分辨率被缓存在中心的更新间隔过去或强制更新之前,不会重新尝试。原始错误:无法传输工件org.springframework:spring-orm:jar:4.2.6.RELEASE from / to central(https://repo.maven.apache.org/maven2):操作已取消。在org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:238)在org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:206)在org.eclipse.aether.internal位于org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve的org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:503)中的.impl.DefaultArtifactResolver.gatherDownloads(DefaultArtifactResolver.java:585)(DefaultArtifactResolver的.java:421)在org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)在org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:367)在
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?
当我去该位置时,我可以清楚地看到Jar文件存在于该位置。我需要在pom.xml中添加其他内容吗?
2 个解决方案
#1
2
Try force refreshing your dependencies. Specifying -U
does that
尝试强制刷新您的依赖项。指定-U会这样做
mvn clean install -U
Edit: You can purge your local release dependencies and to the normal mvn clean install
afterwards:
编辑:您可以在之后清除本地版本依赖项和正常的mvn clean install:
mvn dependency:purge-local-repository
There is not way to force the release dependencies to be pulled, the -U
only works with snapshot dependencies
没有办法强制释放依赖项,-U仅适用于快照依赖项
#2
0
I tried the same pom.xml inEclipse IDE and surprisingly it worked there as it is.
我在Eclipse IDE中尝试了相同的pom.xml,令人惊讶的是它在那里工作。
To make it work on STS, I added following properties
为了使它适用于STS,我添加了以下属性
<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
参考无法下载/导入包org.springframework.cloud.config.server.EnableConfigServer
This worked for me, though I am still curious about the difference.
虽然我仍然对这种差异感到好奇,但这对我有用。
#1
2
Try force refreshing your dependencies. Specifying -U
does that
尝试强制刷新您的依赖项。指定-U会这样做
mvn clean install -U
Edit: You can purge your local release dependencies and to the normal mvn clean install
afterwards:
编辑:您可以在之后清除本地版本依赖项和正常的mvn clean install:
mvn dependency:purge-local-repository
There is not way to force the release dependencies to be pulled, the -U
only works with snapshot dependencies
没有办法强制释放依赖项,-U仅适用于快照依赖项
#2
0
I tried the same pom.xml inEclipse IDE and surprisingly it worked there as it is.
我在Eclipse IDE中尝试了相同的pom.xml,令人惊讶的是它在那里工作。
To make it work on STS, I added following properties
为了使它适用于STS,我添加了以下属性
<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
参考无法下载/导入包org.springframework.cloud.config.server.EnableConfigServer
This worked for me, though I am still curious about the difference.
虽然我仍然对这种差异感到好奇,但这对我有用。