user3006967
user3006967

Reputation: 3545

how to use spring data mongodb and spring cloud together

I am now using this POM to

<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>

to include both spring data mongodb and spring cloud together in a same project. But now, I need to upgrade spring data mongoDB, and this is the POM parent config that I need:

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

Now the problem happened, I still need to keep spring cloud,based on my understanding, I can have only one parent in the pom configuration, so I have to keep spring-cloud-starter-parent, and that should contains spring-boot-starter-parent already. May I ask which version of spring-cloud-starter-parent is equivalent to spring-boot-starter-parent 1.4.1.RELEASE?

I changed to 1.3.7.RELEASE, and got error msg like this in my 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

so what shall I do in this case?

Upvotes: 0

Views: 437

Answers (1)

Jeff
Jeff

Reputation: 1955

Spring cloud can be used with the Spring Boot parent.

As you can see here: http://projects.spring.io/spring-cloud/ So this should do it:

<?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>

Upvotes: 2

Related Questions