1、springboot连接mongodb5报错org.springframework.data.mongodb.UncategorizedMongoDbException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-256, userName='xxx', source='xxx', password=<hidden>, mechanismProperties=<hidden>}; nested exception is com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-256, userName='xxx', source='xxx', password=<hidden>, mechanismProperties=<hidden>}

2、修改配置,加上authentication-database: admin即可解决

spring:
  data:
    mongodb:
      host: 127.0.0.1
      port: 27017
      username: test
      password: test
      database: test
      authentication-database: admin
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐