Spring Boot Mongo DB Configuration with Properties File
Khai báo dependency
của MongoDB trong pom.xml
:
1
2
3
4
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
Cấu hình cho MongoDB ở tệp tin application.properties
:
1
2
3
4
5
6
spring.data.mongodb.authentication-database=admin
spring.data.mongodb.username=root
spring.data.mongodb.password=root
spring.data.mongodb.database=local
spring.data.mongodb.port=27017
spring.data.mongodb.host=localhost
Đọc thêm:
This post is licensed under CC BY 4.0 by the author.