I am using spring boot web application which connects to mongo db which is working out of the box. I just use the following properties:
spring.data.mongodb.h
This will override the Spring Boot autoconfiguration:
@Configuration public class MongoDbSettings { @Bean public MongoClientOptions mongoOptions() { return MongoClientOptions.builder().socketTimeout(2000).build(); } }