Set Mongo Timeout in Spring Boot

后端 未结 7 1155
失恋的感觉
失恋的感觉 2020-12-30 10:21

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         


        
7条回答
  •  春和景丽
    2020-12-30 11:07

    This will override the Spring Boot autoconfiguration:

    @Configuration
    public class MongoDbSettings {
    
        @Bean
        public MongoClientOptions mongoOptions() {
            return MongoClientOptions.builder().socketTimeout(2000).build();
        }
    
    }
    

提交回复
热议问题