Cannot resolve org.springframework.cloud:spring-cloud-starter-netflix-eureka-server:unknown
前言:启动eureka项目,发现右侧maven中的项目dependencies报红,reimport也没用启动类也是报错,一、本地 maven 配置<!--配置本地仓储路径--><localRepository>D:\maven\repository</localRepository><mirror><id>aliyun</id&g
前言:启动eureka项目,发现右侧maven中的项目dependencies报红,reimport也没用,经排查springcloud和springboot版本号没问题。Spring Cloud
启动类也是报错,@EnableEurakaServer注入失败
一、本地 maven 配置、仓库下载
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!--配置本地仓储路径-->
<localRepository>D:\maven\repository</localRepository>
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
</servers>
<mirrors>
<mirror>
<id>aliyun</id>
<name>aliyun Maven</name>
<mirrorOf>central</mirrorOf>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</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>
<activeProfiles>
</activeProfiles>
</settings>
ps:将仓库已有的删除,重新reimport,还是有问题。
二、解决办法
1、在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 启动成功。
2、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>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
再将maven仓库已有的删除,重新reimport,会发现Maven仓库多了一个包 2.1.0.RC2
三、多模块打包出现的问题
maven配置参考博客: https://www.cnblogs.com/alexgl2008/p/13949291.html
每个单独的模块pom.xm中都有配置
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>
1、报错一
Failure to find com.lanren312.projects:xxxxxxxxx:jar:1.0.0 in https://repo.spring.io/milestone was cached in the local repository, resolution will not be reattempted until the update interval of spring-milestones has elapsed or updates are forced -> [Hel
对A模块打包报错:
之前的打包步骤 mvn clean, complie, package
原因:多模块化工程,A模块依赖B模块,B模块没有install
解决办法:在B模块进行 mvn clean, install,再去A模块mvn clean, complie, package就好了
2、报错二
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project gx-game-provider: There are test failures.
更多推荐
所有评论(0)