首页 > 其他分享> > Cannot resolve org.springframework.cloud:spring-cloud-starter-netflix-eureka-server:unknown
Cannot resolve org.springframework.cloud:spring-cloud-starter-netflix-eureka-server:unknown
作者:互联网
Cannot resolve org.springframework.cloud:spring-cloud-starter-netflix-eureka-server:unknown
前言:启动eureka项目,发现右侧maven中的项目dependencies报红,reimport也没用,经排查springcloud和springboot版本号没问题。Spring Cloud
启动类也是报错,@EnableEurakaServer注入失败
一、本地 maven 配置、仓库下载
- <!--配置本地仓储路径-->
- <localRepository>D:\maven\repository</localRepository>
-
- <mirror>
- <id>aliyun</id>
- <name>aliyun Maven</name>
- <mirrorOf>*</mirrorOf>
- <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
- </mirror>
ps:将仓库已有的删除,重新reimport,还是有问题。
二、解决办法,在pom中指定版本号,版本号要和springboot版本号一致。
- <parent>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-parent</artifactId>
- <version>2.1.1.RELEASE</version>
- <relativePath/> <!-- lookup parent from repository -->
- </parent>
-
- <properties>
- <java.version>1.8</java.version>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <spring-cloud.version>Greenwich.RC1</spring-cloud.version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
- <version>2.1.1.RELEASE</version>
- </dependency>
- </dependencies>
最后,重新reimport,右侧 maven 中的项目dependencies报红没了,版本号是刚写的 2.1.1.RELEASE
启动类上的 @EnableEurakaServer 也注入成功,登陆 Euraka 启动成功。
三、idea配置自带的Maven
看了之前同事帮忙的截图,pom中是没有指定版本号的,但右侧的maven的版本号 2.1.0.RC2
同事提了一下这个,里面是https
- <repositories>
- <repository>
- <id>spring-milestones</id>
- <name>Spring Milestones</name>
- <url>https://repo.spring.io/milestone</url>
- </repository>
- </repositories>
同事还帮忙指出了两个解决办法,一是将jdk版本提高到1.8.0.33以上,第二个使用默认的maven
找到idea的安装路径 D:\Program Files\JetBrains\IntelliJ IDEA 2020.1\plugins\maven\lib\maven3\conf
配置maven本地仓库,注意看标签位置
- <!-- localRepository
- | The path to the local repository maven will use to store artifacts.
- |
- | Default: ${user.home}/.m2/repository
- <localRepository>/path/to/local/repo</localRepository>
- -->
- <!--配置本地仓储路径-->
- <localRepository>D:\maven\repository</localRepository>
配置阿里云加快下载速度,注意看标签位置
- <mirrors>
- <!-- mirror
- | Specifies a repository mirror site to use instead of a given repository. The repository that
- | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
- | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
- |
- <mirror>
- <id>mirrorId</id>
- <mirrorOf>repositoryId</mirrorOf>
- <name>Human Readable Name for this Mirror.</name>
- <url>http://my.repository.com/repo/path</url>
- </mirror>
- -->
-
- <mirror>
- <id>aliyun</id>
- <name>aliyun Maven</name>
- <mirrorOf>*</mirrorOf>
- <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
- <mirrorOf>central</mirrorOf>
- </mirror>
-
- </mirrors>
- <profiles>
- <profile>
- <id>jdk-1.8</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- <jdk>1.8</jdk>
- </activation>
- <properties>
- <maven.compiler.source>1.8</maven.compiler.source>
- <maven.compiler.target>1.8</maven.compiler.target>
- <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
- </properties>
- </profile>
- </profiles>
再将maven仓库已有的删除,重新reimport,会发现Maven仓库多了一个包 2.1.0.RC2
到此问题就全部解决了。
https://blog.csdn.net/lanren312/article/details/124746350标签:resolve,repository,netflix,版本号,spring,1.8,maven,aliyun,cloud 来源: https://www.cnblogs.com/sunny3158/p/16631828.html