From 1356a61044bc69de8102853e93a747acc2c0af6c Mon Sep 17 00:00:00 2001 From: yixian Date: Sat, 11 Jul 2020 00:27:15 +1000 Subject: [PATCH] fix initialize --- .../payment/manage/PaymentManageApplication.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/PaymentManageApplication.java b/src/main/java/au/com/royalpay/payment/manage/PaymentManageApplication.java index b84648e5f..aa40b3c5b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/PaymentManageApplication.java +++ b/src/main/java/au/com/royalpay/payment/manage/PaymentManageApplication.java @@ -4,15 +4,13 @@ import com.alibaba.fastjson.parser.ParserConfig; import com.google.code.kaptcha.Producer; import com.google.code.kaptcha.impl.DefaultKaptcha; import com.google.code.kaptcha.util.Config; - import com.maxmind.geoip.LookupService; -import com.mongodb.MongoClientOptions; - import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.boot.autoconfigure.mongo.MongoClientSettingsBuilderCustomizer; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; import org.springframework.core.io.Resource; @@ -23,6 +21,7 @@ import java.io.IOException; import java.util.Properties; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; /** * exclude = {DataSourceAutoConfiguration.class} @@ -78,7 +77,9 @@ public class PaymentManageApplication { } @Bean - public MongoClientOptions mongoOptions() { - return MongoClientOptions.builder().maxConnectionIdleTime(6000).socketTimeout(3000).maxWaitTime(3000).serverSelectionTimeout(3000).build(); + public MongoClientSettingsBuilderCustomizer mongoOptions() { + return builder -> builder.applyToConnectionPoolSettings(config -> config.maxWaitTime(3, TimeUnit.SECONDS) + .maxConnectionIdleTime(6, TimeUnit.SECONDS) + ).applyToSocketSettings(config -> config.connectTimeout(3, TimeUnit.SECONDS)); } }