简体   繁体   中英

Upgrade mongo db to 3.2 in spring boot application

I am using spring boot 1.2.8 with Mongo db 2.4.10. I am planning to upgrade mongo db to 3.2.0.

So with current sprinb boot 1.2.8 i use below in pom,

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>

I see in the dependency hierarchy it comes with mongo-java-driver version 2.12.5

But i read in mongo java driver doc , it says even with version 2.14, it does not support all MongoDB 3.2 features (eg, read concern)

So i upgrade spring boot to the latest version of 1.3.3 expecting i would get a mongo-java-driver version 3.2 which support all mongo db 3.2 features.

But i get mongo-java-driver 2.13.3 with Springboot 1.3.3

So how can i upgrade my application to support mongo db version 3.2?

Edit:

With the latest spring boot 1.3.4 below is the hierarchy,

spring-boot-starter-data-mongodb 1.3.4 [compile]
    -mongo-java-driver 2.13.3 [compile]
        -spring-data-mongodb 1.8.4 [compile]
              -mongo-java-driver 2.13.3 [omitted for conflict with 2.13.3]

The ref doc says, What's new in Spring Data MongoDB 1.9=>Assert compatibility with MongoDB 3.0 and MongoDB Java Driver 3.2

What's new in Spring Data MongoDB 1.7=>Assert compatibility with MongoDB 3.0 and MongoDB Java Driver 3-beta3

So is it correct to say, if i use spring boot 1.3.4 with just above mentioned spring boot 1.3.4, it will support all features of mongo db 3.2, although i get spring-data-mongodb 1.8.4?

Spring Data MongoDB builds on top of MongoDB's Java driver. It uses it to communicate with a MongoDB instance. To use Spring Data MongoDB you need both it and the Java driver.

Spring Data MongoDB support the 3.x driver . To use it you can override the driver's version that's configured by Spring Boot by adding the following to your pom:

<properties>
    <mongodb.version>3.2.2</mongodb.version>
</properties>

Use below tags in pom.xml file and you dont have to worry about spring version.You need not mention any spring boot jar version in pom.xml file.Spring IO platform take cares of it to include compatible jars.

 <parent>
    <groupId>io.spring.platform</groupId>
    <artifactId>platform-bom</artifactId>
    <version>2.0.1.RELEASE</version>
</parent>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM