错误如下:
Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='', source='test', password=<hidden>, mechanismProperties={}}; nested exception is com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='', source='test', password=<hidden>, mechanismProperties={}}"}
原因和解决方法:
因为在properties中配置了两句:
spring.data.mongodb.username=
spring.data.mongodb.password=
导致需要用户名和密码,username就是'',password就是hidden MongoDB如果没有特殊配置不要写下面两条语句
解决方法:去掉这两句就行了
本文详细解析了MongoDB连接认证失败的问题,特别是由于Spring Boot应用中配置文件的不当设置导致的错误。通过调整配置,避免了空用户名和隐藏密码的问题,从而解决了连接失败的情况。

3699

被折叠的 条评论
为什么被折叠?



