How to use Spring to connect to MongoDB which requires authentication
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am using the below Spring configuration in order to connect to mongoDB where mongo.url=mongodb:// : @ :27017 However I'm getting an authetication error. My understanding was that MongoUI can take a URL in the above format. I know that mongoTemplate can accept userCredentials object however I would need to extract them from the URL first and i'm not sure how to do that in the configuration. Any idea how can I change my config above to suppot this assuming mongo.url format cannot be changed? 回答1: found the solution using Spring