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.host=myHost
spring.data.mongodb.port=27017
spring.data.mongodb.database=myDatabase
spring.data.mongo.repositories.enabled=true
spring.data.mongodb.username=myUser
spring.data.mongodb.password=myPassword
The default timeout to MongoDB is 10 seconds. I would like to configure the timeout. I tried doing
spring.data.mongodb.socketTimeout=2
or spring.data.mongodb.connectionTimeout=2
None of the properties work. Is it something that I can specify in the properties and the Spring framework will take care of it or can someone give example of doing it by declaring the Bean.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…