客戶端即連接池巍沙,需要重寫連接池
引入依賴
<dependency>
<groupId>com.spring4all</groupId>
<artifactId>mongodb-plus-spring-boot-starter</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
啟動(dòng)類添加注解
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一樣也需要建立索引
項(xiàng)目新版本上線后上午還一切正常,下午就卡得根本用不了。排查了各種服務(wù)的連接啄刹,虛擬機(jī)等等蜘欲,最終確定是未建立索引的緣故。
語(yǔ)法如下:
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})