在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是数据库名字,改为自己的

相关推荐
一 乐8 小时前
动漫书销售商城|基于springboot + vue动漫书销售商城(源码+数据库+文档)
java·数据库·vue.js·spring boot·毕业设计
旺仔学长 哈哈9 小时前
springboot钓鱼爱好者交流平台APP设计与实现
java·spring boot·mysql·充电桩管理系统
Wx-bishekaifayuan9 小时前
django个性化旅游路线推荐平台49005-计算机课程设计、毕业设计
spring boot·后端·python·django·课程设计·express·旅游
FYKJ_201013 小时前
django电影推荐系统55066-计算机课程设计、毕业设计
vue.js·spring boot·python·mysql·typescript·spark·django
Wx-bishekaifayuan14 小时前
springboot生活易购超市管理系统54086-计算机课程设计、毕业设计
spring boot·后端·python·django·课程设计·express·旅游
计算机毕设定制辅导-无忧学长15 小时前
《基于Spring Boot的减脂轻食购物网站》
java·vue.js·spring boot·后端·减脂轻食购物网站
沐欣工作室_lvyiyi15 小时前
基于SpringBoot的博物馆预约系统设计与实现(论文+源码)
java·spring boot·后端·计算机毕业设计
一 乐16 小时前
博客管理系统|基于springboot + vue博客管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·毕设