Example usage for org.springframework.data.mongodb.core MongoClientFactoryBean MongoClientFactoryBean

List of usage examples for org.springframework.data.mongodb.core MongoClientFactoryBean MongoClientFactoryBean

Introduction

In this page you can find the example usage for org.springframework.data.mongodb.core MongoClientFactoryBean MongoClientFactoryBean.

Prototype

MongoClientFactoryBean

Source Link

Usage

From source file:com.card.loop.xyz.config.AppConfig.java

@Bean
public Mongo mongo() throws Exception {
    MongoClientFactoryBean mongo = new MongoClientFactoryBean();
    mongo.setSingleton(false);//from  w w  w .  j  a  va2  s .c  o  m
    mongo.setHost(mongodb_host);
    mongo.setPort(mongodb_port);
    Builder builder = MongoClientOptions.builder();
    builder.connectionsPerHost(AppConfig.connectionsPerHost);
    builder.connectTimeout(AppConfig.connectionTimeOut);
    return mongo.getObject();
}