简体   繁体   中英

Need for mongo-java-driver with Spring-data-MongoDB

I am new to mongoDB and Spring so want some clarification.

I went through many tutorials some just use

<dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-mongodb</artifactId>
        <version>1.7.2.RELEASE</version>
</dependency>

while others use :

<dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-mongodb</artifactId>
        <version>1.7.2.RELEASE</version>
</dependency>
<dependency>
        <groupId>org.mongodb</groupId>
        <artifactId>mongo-java-driver</artifactId>
        <version>2.11.0</version>
</dependency>

So what is the use of mongo-java-driver ? and why is it required if we can connect to mongoDB without it?

You only combine them when

  1. You are using Spring Data Framework (otherwise, you'd only need the Mongo driver)

  2. You want to use a Mongo Driver other than 2.13.0, which is included already (referring to your first POM)

See Compile dependencies

By the way 1.7.2.RELEASE was released 2015, so best go upgrade

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