@[TOC](org.springframework.data.mongodb.UncategorizedMongoDbException: Query failed with error code 13 with name ‘Unauthorized’ and error message ‘command find requires authentication’ on server 192.168.21.148:27017; nested exception is com.mongodb.MongoQueryException: Query failed with error code 13 with name ‘Unauthorized’ and error message ‘command find requires authentication’ on server 192.168.21.148:27017 at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:140) at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:3048) at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:2984) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:2670) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:2652) at org.springframework.data.mongodb.core.MongoTemplate.find(M)

解决

spring:
  data:
    mongodb:
      host: 192.168.21.148
      port: 27017
      username: root
      password: '123456'
      database: admin
      authenticationDatabase: admin

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐