Search code examples
javamongodbspring-bootmavenspring-data

I am trying to connect mongodb with spring boot. I am confused when to use which maven dependency amongst the following:


I am trying to connect mongodb with spring boot. I want to configure using AbstractMongoClientConfiguration, MongoConfigurationSupport abstract classes and MongoClient class and use MongoTemplate, MongoRepository and MongoClient. I am confused when to use which maven dependency amongst the following:

  1. org.mongodb mongodb-driver-sync
  2. org.mongodb mongo-java-driver
  3. org.springframework.data spring-data-mongodb
  4. org.springframework.boot spring-boot-starter-data-mongodb

Can someone please help?


Solution

  • Try this, according to Baeldung tutorial https://www.baeldung.com/spring-data-mongodb-tutorial

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