只需将spring-boot-dependencies导入为pom,就无法解析spring cloud依赖关系

时间:2018-04-28 09:46:32

标签: maven spring-boot spring-cloud

版本: springboot-2.0.0.RELEASE springcloud-Finchley.RC1

我的项目依赖于spring-cloud-starter-netflix-eureka-client, 当我将spring-boot-starter-parent声明为下面的父级时,Idea可以重新启动eureka-client的版本,

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.RELEASE</version>
</parent>

但是当我像下面的pom一样导入spring-boot-dependencies时,Idea无法恢复eureka-client的版本, 为什么?

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>2.0.0.RELEASE</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>

spring-boot-starter-parent-2.0.0.RELEASE.pom文件几乎只导入头部的spring-boot-dependencies

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-dependencies</artifactId>
    <version>2.0.0.RELEASE</version>
    <relativePath>../../spring-boot-dependencies</relativePath>
</parent>

加上,我导入如下弹簧云

<dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dependencies</artifactId>
        <version>Finchley.RC1</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>

1 个答案:

答案 0 :(得分:0)

也许将spring-cloud-dependencies放入dependencyManagement块中,如下所示:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>