In this tutorial, we're going to see different ways to configure a connection to our To run the full test suite, a MongoDB Replica Set is required. The Spring Data MongoDB project aims to provide a familiar and consistent Spring-based programming model for new datastores while retaining store-specific features and capabilities. I suspect that you may have an authentication issue, try specifying the credentials of your mongodb when configuring your db-factory. I have added First, we need to include spring boot artifact spring-boot-starter-data-mongodb in our pom.xml to download the Step 2: Setup XML configurations. @Bean public MongoDbFactory mongoDbFactory() throws UnknownHostException{ Spring Boot by default attempts to connect to a locally hosted instance of MongoDB, using the test database. I have tried passing the setting the connection spring in the application.properties -> spring.data.mongodb.uri= I am getting the below errors: (2.3.1) with similar Spring configuration and Java Driver (4.0.4). The Spring Data MongoDB project applies core Spring concepts to the development of solutions that use the MongoDB document style data store. In your mongoTemplate you have referred to mongoDBFactory, but you do not have id attribute specified for the factory.