Springboot配置MongoDB连接增加mongoplus支持
一共三步
一,
<!-- 增加mongoplus支持 --> <dependency> <groupId>com.spring4all</groupId> <artifactId>mongodb-plus-spring-boot-starter</artifactId> <version>1.0.0.RELEASE</version> </dependency>
二,
spring: data: mongodb: uri: mongodb://地址 option: socket-keep-alive: true max-connection-idle-time: 60000 # connect-timeout: 36000 # min-connection-per-host: 5 # threads-allowed-to-block-for-connection-multiplier: 5 # max-wait-time: 120000 # socket-timeout: 0 # max-connection-life-time: 0 # heartbeat-socket-timeout: 36000 # heartbeat-connect-timeout: 36000 # min-heartbeat-frequency: 5 # heartbeat-frequency: 10
三.项目启动类SpringBootMainApplication上添加一个注解@EnableMongoPlus。
参考:1.https://www.cnblogs.com/kylne/p/11193878.html
2.https://blog.51cto.com/14923682/2532317