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

项目依赖了spring-cloud-starter-netflix-eureka-client,但是没有指定版本,想通过dependencyManagement 统一管理依赖版本,结果项目构建 reimport 时报错:
Cannot resolve org.springframework.cloud:spring-cloud-starter-netflix-eureka-client:unknown

经排查,是在引入依赖管理dependencyManagement时少了type和scope两个字段。

错误的举例

 <dependencyManagement>
      <dependencies>
           <dependency>
               <groupId>org.springframework.cloudgroupId>
               <artifactId>spring-cloud-dependenciesartifactId>
               <version>2020.0.3version>
           dependency>
       dependencies>
   dependencyManagement>

正确的使用方式

  • 指定type为pom
  • 指定scope为import
<dependencyManagement>
 	<dependencies>
        <dependency>
            <groupId>org.springframework.cloudgroupId>
            <artifactId>spring-cloud-dependenciesartifactId>
            <version>2020.0.3version>
            <type>pomtype>
            <scope>importscope>
        dependency>
    dependencies>
dependencyManagement>

你可能感兴趣的:(Java)