MongoDB is a provider of Spring Boot for handling NoSQL database operations. To use MongoDB in your Spring boot application you have to add this MongoDB starter in your pom.xml .
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
After adding MongoDB starter in your application it will automatically download and add the required dependencies in your application and initialize with default values. You can overwrite these values through application.properties / application.yaml .
Embedded MongoDB Configuration Properties
Spring Boot load these properties in EmbeddedMongoProperties class.
Name | Default Value | Description |
spring.mongodb.embedded.features | SYNC_DELAY | Comma-separated features to enable. |
spring.mongodb.embedded.storage.database-dir | Directory used for data storage. | |
spring.mongodb.embedded.storage.oplog-size | Maximum size of the oplog in megabytes. | |
spring.mongodb.embedded.storage.repl-set-name | Name of the replica set. | |
spring.mongodb.embedded.version | 2.6.10 | Version of Mongo to use. |
MongoDB Configuration Properties
Spring Boot load these properties in MongoProperties class.
Name | Default Value | Description |
spring.data.mongodb.authentication-database | Authentication database name. | |
spring.data.mongodb.database | test | Database name. |
spring.data.mongodb.field-naming-strategy | USe Fully qualified name of the FieldNamingStrategy. | |
spring.data.mongodb.grid-fs-database | GridFS database name. | |
spring.data.mongodb.host | localhost | Mongo server host. |
spring.data.mongodb.password | Login password of the mongo server. | |
spring.data.mongodb.port | 27017 | Mongo server port. |
spring.data.mongodb.repositories.enabled | true | Enable Mongo repositories. |
spring.data.mongodb.uri | mongodb://localhost/test | Mongo database URI.host and port are ignored when setting it. |
spring.data.mongodb.username | Login user of the mongo server. |
References
https://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html
You must log in to post a comment.