I'm working on a project in which I have store csv file data in my mongodb. If the database is not exist then I have to create it using springboot and if does exist then I have to directly store the data in db
Previously I stored all the data in "admin" database in mongodb.
Below is the for the same. In my properties file I specified this.
spring.data.mongodb.authentication-database=admin
spring.data.mongodb.uri=mongodb://localhost:27017/admin
spring.data.mongodb.database=admin
spring.data.mongodb.repositories.enabled=true
CodePudding user response:
you don't need to create a database just replace admin with the name of the database you want to create mongoDB will create automatically
like this :-
spring.data.mongodb.uri=mongodb://localhost:27017/newDatabaseName
spring.data.mongodb.database=newDatabaseName