mongodb+unauthor_springboot集成mongoDB需要认证

在尝试使用SpringBoot集成MongoDB时遇到了'command update requires authentication'的错误,原因是未进行身份验证。通过更新配置文件,将用户名和密码加入到URI中解决了此问题。
摘要由CSDN通过智能技术生成

报错:

Mon Nov 25 01:09:48 CST 2019

There was an unexpected error (type=Internal Server Error, status=500).

Command failed with error 13 (Unauthorized): ‘command update requires authentication‘ on server 192.168.180.113:27017. The full response is {"ok": 0.0, "errmsg": "command update requires authentication", "code": 13, "codeName": "Unauthorized"}; nested exception is com.mongodb.MongoCommandException: Command failed with error 13 (Unauthorized): ‘command update requires authentication‘ on server 192.168.180.113:27017. The full response is {"ok": 0.0, "errmsg": "command update requires authentication", "code": 13, "codeName": "Unauthorized"}

org.springframework.data.mongodb.UncategorizedMongoDbException: Command failed with error 13 (Unauthorized): ‘command update requires authentication‘ on server 192.168.180.113:27017. The full response is {"ok": 0.0, "errmsg": "command update requires authentication", "code": 13, "codeName": "Unauthorized"}; nested exception is com.mongodb.MongoCommandException: Command failed with error 13 (Unauthorized): ‘command update requires authentication‘ on server 192.168.180.113:27017. The full response is {"ok": 0.0, "errmsg": "command update requires authentication", "code": 13, "codeName": "Unauthorized"}

报错的配置:

spring:

application:

name: spring-boot-mongodb

data:

mongodb:

username: test

password:123456uri: mongodb://192.168.180.113:27017/test

解决:

spring:

application:

name: spring-boot-mongodb

data:

mongodb:

uri: mongodb://test:[email protected]:27017/test

原文:https://www.cnblogs.com/dalianpai/p/11925480.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值