【问题标题】:can not resolve spring cloud dependency when just import spring-boot-dependencies as pom仅将 spring-boot-dependencies 导入为 pom 时无法解决 Spring Cloud 依赖关系
【发布时间】:2018-10-09 01:13:01
【问题描述】:

版本: 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>

但是当我像下面这样将 spring-boot-dependencies 导入为 pom 时,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>

另外,我像下面这样导入spring cloud

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

【问题讨论】:

  • 这是使用 Spring Cloud 的文档化方法。 Spring boot 对此一无所知。
  • 我更新了我的问题,spring-boot-starter-parent-2.0.0.RELEASE.pom 文件几乎只在文件头导入 spring-boot-dependencies,所以我认为这两个方式应该都可以。
  • 嗨,最后找到解决办法了吗?我搜索了这个问题并点击了这里,一年后当这是发布时,仍然看不到任何解决方案。大声笑

标签: maven spring-boot spring-cloud


【解决方案1】:

也许像这样将 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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-13
    • 2019-07-29
    • 2021-07-24
    • 2020-06-21
    • 2014-05-07
    • 2018-09-21
    • 2019-12-13
    • 2020-07-20
    相关资源
    最近更新 更多