springboot集成mongoDB需要认证
Posted 天宇轩-王
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springboot集成mongoDB需要认证相关的知识,希望对你有一定的参考价值。
报错:
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: 123456 uri: mongodb://192.168.180.113:27017/test
解决:
spring: application: name: spring-boot-mongodb data: mongodb: uri: mongodb://test:123456@192.168.180.113:27017/test
以上是关于springboot集成mongoDB需要认证的主要内容,如果未能解决你的问题,请参考以下文章
Spring security OAuth2.0认证授权学习第四天(SpringBoot集成)
Spring security OAuth2.0认证授权学习第四天(SpringBoot集成)
前后端分离项目中 springboot 集成 shiro 实现权限控制
项目总结52: Linux安装mongodb和Springboot集成mongodb