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
To follow your theme, this would be the best to answer your question. Looks like you would like to set a timeout in your application.properties file.
In order to do so:
Instead of
spring.data.mongodb.host=myHost
spring.data.mongodb.port=27017
spring.data.mongodb.database=myDatabase
spring.data.mongodb.username=myUser
spring.data.mongodb.password=myPassword
Try this
spring.data.mongodb.uri=mongodb://myUser:myPassword@myHost:27017,myHost:27017/myDatabase?serverSelectionTimeoutMS=2000&connectTimeoutMS=2000
spring.data.mongodb.database=myDatabase
spring.data.mongo.repositories.enabled=true
Modify time in milliseconds to desired time.