【问题标题】:how to use spring data mongodb and spring cloud together如何一起使用spring data mongodb和spring cloud
【发布时间】:2017-02-02 01:53:56
【问题描述】:

我现在正在使用这个 POM 来

<parent>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-parent</artifactId>
        <version>1.0.0.RELEASE</version>
    </parent>
<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>   
        </dependency>

在同一个项目中同时包含 spring data mongodb 和 spring cloud。但是现在,我需要升级spring data mongoDB,这是我需要的POM父配置:

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

现在问题发生了,我仍然需要保留spring cloud,根据我的理解,我的pom配置中只能有一个父级,所以我必须保留spring-cloud-starter-parent,并且应该包含spring -boot-starter-parent 已经。请问spring-cloud-starter-parent哪个版本相当于spring-boot-starter-parent 1.4.1.RELEASE?

我更改为 1.3.7.RELEASE,并在我的 IDE 中收到这样的错误消息:

Project build error: Non-resolvable parent POM for org.test:ngcsc-api:0.0.1-SNAPSHOT: Failure to find org.springframework.cloud:spring-cloud-starter-
     parent:pom:1.3.7.RELEASE in https://repository.cloudera.com/artifactory/cloudera-repos/ was cached in the local repository, resolution will not be reattempted 
     until the update interval of cloudera has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM

那么在这种情况下我该怎么办?

【问题讨论】:

    标签: spring spring-boot spring-data spring-cloud


    【解决方案1】:

    Spring Cloud 可以与 Spring Boot 父级一起使用。

    如您所见:http://projects.spring.io/spring-cloud/ 所以应该这样做:

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>1.4.1.RELEASE</version>
        </parent>
        <artifactId>Spring Boot</artifactId>
        <name>Mongo</name>
        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-dependencies</artifactId>
                    <version>Brixton.SR6</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-config</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-data-mongodb</artifactId>
                <exclusions>
                    <exclusion>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-logging</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
        </dependencies>
    </project>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-21
      • 2017-01-13
      • 1970-01-01
      • 2016-12-10
      • 1970-01-01
      • 2017-11-07
      • 1970-01-01
      • 2019-03-05
      相关资源
      最近更新 更多