解决mongodb连接的失败的问题

连接mongodb的时候报错

Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='admin', source='admin', password=, mechanismProperties=}; nested exception is com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='admin', source='admin', password=, mechanismProperties=}

连接配置信息

  data:
    mongodb:
      uri: mongodb://127.0.0.1:27017
      username: admin
      password: 123456
      authenticationDatabase: admin
      database: admin

最后在debug的时候发现,MongoProperties 中密码是空的,MongoProperties中的password

private char[] password;

修改配置文件 密码为字符串

  data:
    mongodb:
      uri: mongodb://127.0.0.1:27017
      username: admin
      password: "123456"
      authenticationDatabase: admin
      database: admin

你可能感兴趣的:(解决mongodb连接的失败的问题)