• Cannot resolve org.springframework.cloud:springcloudstarternetflixeurekaserver:unknown


    Cannot resolve org.springframework.cloud:spring-cloud-starter-netflix-eureka-server:unknown

    前言:启动eureka项目,发现右侧maven中的项目dependencies报红,reimport也没用,经排查springcloud和springboot版本号没问题。Spring Cloud

     启动类也是报错,@EnableEurakaServer注入失败

    一、本地 maven 配置、仓库下载

    1. <!--配置本地仓储路径-->
    2. <localRepository>D:\maven\repository</localRepository>
    3. <mirror>
    4. <id>aliyun</id>
    5. <name>aliyun Maven</name>
    6. <mirrorOf>*</mirrorOf>
    7. <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    8. </mirror>

     

    ps:将仓库已有的删除,重新reimport,还是有问题。

    二、解决办法,在pom中指定版本号,版本号要和springboot版本号一致。

    1. <parent>
    2. <groupId>org.springframework.boot</groupId>
    3. <artifactId>spring-boot-starter-parent</artifactId>
    4. <version>2.1.1.RELEASE</version>
    5. <relativePath/> <!-- lookup parent from repository -->
    6. </parent>
    7. <properties>
    8. <java.version>1.8</java.version>
    9. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    10. <spring-cloud.version>Greenwich.RC1</spring-cloud.version>
    11. </properties>
    12. <dependencies>
    13. <dependency>
    14. <groupId>org.springframework.cloud</groupId>
    15. <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
    16. <version>2.1.1.RELEASE</version>
    17. </dependency>
    18. </dependencies>

    最后,重新reimport,右侧 maven 中的项目dependencies报红没了,版本号是刚写的 2.1.1.RELEASE

    启动类上的 @EnableEurakaServer 也注入成功,登陆 Euraka 启动成功。

    三、idea配置自带的Maven

    看了之前同事帮忙的截图,pom中是没有指定版本号的,但右侧的maven的版本号 2.1.0.RC2

    同事提了一下这个,里面是https

    1. <repositories>
    2. <repository>
    3. <id>spring-milestones</id>
    4. <name>Spring Milestones</name>
    5. <url>https://repo.spring.io/milestone</url>
    6. </repository>
    7. </repositories>

    同事还帮忙指出了两个解决办法,一是将jdk版本提高到1.8.0.33以上,第二个使用默认的maven

    找到idea的安装路径 D:\Program Files\JetBrains\IntelliJ IDEA 2020.1\plugins\maven\lib\maven3\conf

    配置maven本地仓库,注意看标签位置

    1. <!-- localRepository
    2. | The path to the local repository maven will use to store artifacts.
    3. |
    4. | Default: ${user.home}/.m2/repository
    5. <localRepository>/path/to/local/repo</localRepository>
    6. -->
    7. <!--配置本地仓储路径-->
    8. <localRepository>D:\maven\repository</localRepository>

    配置阿里云加快下载速度,注意看标签位置

    1. <mirrors>
    2. <!-- mirror
    3. | Specifies a repository mirror site to use instead of a given repository. The repository that
    4. | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
    5. | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
    6. |
    7. <mirror>
    8. <id>mirrorId</id>
    9. <mirrorOf>repositoryId</mirrorOf>
    10. <name>Human Readable Name for this Mirror.</name>
    11. <url>http://my.repository.com/repo/path</url>
    12. </mirror>
    13. -->
    14. <mirror>
    15. <id>aliyun</id>
    16. <name>aliyun Maven</name>
    17. <mirrorOf>*</mirrorOf>
    18. <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    19. <mirrorOf>central</mirrorOf>
    20. </mirror>
    21. </mirrors>
    1. <profiles>
    2. <profile>
    3. <id>jdk-1.8</id>
    4. <activation>
    5. <activeByDefault>true</activeByDefault>
    6. <jdk>1.8</jdk>
    7. </activation>
    8. <properties>
    9. <maven.compiler.source>1.8</maven.compiler.source>
    10. <maven.compiler.target>1.8</maven.compiler.target>
    11. <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
    12. </properties>
    13. </profile>
    14. </profiles>

    再将maven仓库已有的删除,重新reimport,会发现Maven仓库多了一个包 2.1.0.RC2

     到此问题就全部解决了。

    https://blog.csdn.net/lanren312/article/details/124746350
  • 相关阅读:
    委托
    apply()和call()
    Sql小技巧
    plsql中文乱码
    Windows8中使用IE8等低版本浏览器
    React Native
    谷歌浏览器添加flash白名单
    jsonp原理详解
    垂直居中
    window.moveTo(),window.moveBy()不生效
  • 原文地址:https://www.cnblogs.com/sunny3158/p/16631828.html
Copyright © 2020-2023  润新知