客户端即连接池,需要重写连接池
引入依赖
<dependency>
<groupId>com.spring4all</groupId>
<artifactId>mongodb-plus-spring-boot-starter</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
启动类添加注解
package com.hmb.pdloan;
import com.hmb.pdloan.peoperties.listener.PropertiesListener;
import com.spring4all.mongodb.EnableMongoPlus;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
@EnableMongoPlus
@ComponentScan
@EnableAutoConfiguration
public class Applaction {
ymal配置
data:
mongodb:
database: pdloan
# host: 193.112.201.105
host: 127.0.0.1
port: 27017
option:
min-connection-per-host: 50
max-connection-per-host: 200
max-connection-idle-time: 10000
同mysql一样也需要建立索引
项目新版本上线后上午还一切正常,下午就卡得根本用不了。排查了各种服务的连接,虚拟机等等,最终确定是未建立索引的缘故。
语法如下:
db.yuqian_mf_detail.createIndex({"tid":1})
db.yuqian_multi_noauth.createIndex({"tid":1})
db.yuqian_wyjt.createIndex({"tid":1})
db.yuqian_wyjt_contact.createIndex({"tid":1})
db.yuqian_wyjt_detail.createIndex({"tid":1})
db.yuqian_ypz.createIndex({"tid":1})
db.yuqian_ypz_detail.createIndex({"tid":1})
网友评论