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

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

Introduction

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

Prototype

public void setHost(@Nullable String host) 

Source Link

Document

Configures the host to connect to.

Usage

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

@Bean
public Mongo mongo() throws Exception {
    MongoClientFactoryBean mongo = new MongoClientFactoryBean();
    mongo.setSingleton(false);/*w  ww . j av a 2  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();
}