在SpringBoot使用MongoDB时出现的bug和解决

在springboot使用MongoDB时出现的bug和解决

在springboot整合MongoDB时,报错

INFO 67135 --- [ main] org.mongodb.driver.connection : Closed connection [connectionId{localValue:2}] to 127.0.0.1:27017 because there was a socket exception raised by this connection.

org.springframework.data.mongodb.UncategorizedMongoDbException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='root', source='demo', password=, mechanismProperties=}; nested exception is com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='root', source='demo', password=, mechanismProperties=}

报错的话说是权限 什么的,可以把properties 文件中mongodb.uri改一下:

spring.data.mongodb.uri=mongodb://root:123456@127.0.0.1:27017/demo?authSource=admin&authMechanism=SCRAM-SHA-1

root是账号,123456是密码,demo是数据库名字,改为自己的

相关推荐
m0_7482338814 分钟前
Spring Boot 集成 MyBatis 全面讲解
spring boot·后端·mybatis
抽象具象化43 分钟前
BUG日志:使用热点或免费加速器时git链接github出现端口22拒绝访问的解决方法
git·github·bug
快乐非自愿1 小时前
Spring Boot集成Spring Security之HTTP请求授权
spring boot·spring·http
不懂901 小时前
Spring Boot集成Jetty、Tomcat或Undertow及支持HTTP/2协议
spring boot·后端·http·https
代码小白%2 小时前
快速理解Spring 和 Spring Boot 的核心区别
java·spring boot·spring
工业互联网专业2 小时前
基于springboot+vue的融合多源高校画像数据与协同过滤算法的高考择校推荐系统
java·vue.js·spring boot·毕业设计·源码·课程设计·高考择校推荐系统
虎鲸不是鱼3 小时前
【全栈开发】从0开始搭建一个图书管理系统【一】框架搭建
java·spring boot·spring·maven·mybatis
IT闫3 小时前
【SpringBoot】——如何在Spring Boot中使用ThreadLocal来存储和获取用户详情信息以及实体类参数验证
java·spring boot·后端
编程诗人华仔4 小时前
若依框架实际国际化前后端统一解决方案
java·vue.js·spring boot·后端·elementui
库库林_沙琪马6 小时前
解决Spring Boot中LocalDateTime返回前端数据为数组结构的问题
java·spring boot·后端