引入所需依赖
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
</dependencies>
添加配置文件
spring.data.mongodb.uri=mongodb://192.168.80.10:27017/test
测试运行
基于MongoTemplate开发CRUD
基于MongoRepository开发CRUD
代码仓库地址https://gitee.com/czshh0628/springboot2020/blob/master/spring-boot-mongodb-demo