This commit is contained in:
尹吉欢
2017-10-31 09:37:10 +08:00
parent 0b72685153
commit f3eb02dcdf
2 changed files with 6 additions and 4 deletions
@@ -20,13 +20,13 @@ public class SpringMongoConfig {
public @Bean MongoDbFactory mongoDbFactory() throws Exception {
List<ServerAddress> seeds = Arrays.asList(new ServerAddress("mongo.db.fangjia.com", 27017));
MongoClientOptions.Builder builder = new MongoClientOptions.Builder();
int connPerHost = 20;
int connPerHost = 10;
builder.connectionsPerHost(connPerHost);
int threadCount = 20;
int threadCount = 10;
builder.threadsAllowedToBlockForConnectionMultiplier(threadCount);
int maxWaitTime = 1000;
int maxWaitTime = 10000;
builder.maxWaitTime(maxWaitTime);
int timeOut = 1000;
int timeOut = 10000;
builder.connectTimeout(timeOut);
MongoClientOptions options = builder.build();
MongoClient mongoClient = new MongoClient(seeds, options);
@@ -26,6 +26,8 @@
<property name="url" value="${spring.datasource.url}"/>
<property name="username" value="${spring.datasource.username}"/>
<property name="password" value="${spring.datasource.password}"/>
<property name="validationQuery" value="SELECT 1" />
<property name="testOnBorrow" value="true"/>
</bean>
<bean id="cxytiandiJdbcTemplate" class="com.cxytiandi.jdbc.CxytiandiJdbcTemplate">