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

相关推荐
小科先生30 分钟前
Java springboot调用数据库的基本流程
java·数据库·spring boot
海拥✘5 小时前
让 AI 修 AI 平台自己的 Bug:我用 SoduWork 给 SoduWork 提了一个 PR
人工智能·bug
杨凯凡6 小时前
Spring Boot 链路追踪实战:Micrometer、TraceId 与异步线程上下文传播
java·spring boot·后端
计算机毕设定制辅导-无忧学长7 小时前
《基于Spring Boot的迷游哈游戏综合服务平台的开发》
java·vue.js·spring boot·mysql·迷游哈游戏综合服务平台
梦想恒远20 小时前
Spring Boot + LangChain4j 统计 token 成本:ChatModelListener 实测与单价口径
spring boot·后端
howard20051 天前
Spring Boot 版新生报到可视化系统
spring boot·新生报到可视化系统
她的男孩1 天前
子表只读列界面能改,保存却报不允许编辑:Forge Admin 把字段权限落到子表列
spring boot·低代码·工作流引擎
希和20271 天前
51 单片机入门笔记:江科大课程代码逐行讲解(按键控制 LED 流水灯)
笔记·单片机·mongodb
杨凯凡1 天前
MySQL 死锁怎么排查?InnoDB 锁等待与 Spring Boot 整事务重试实战
数据库·spring boot·mysql
希和20271 天前
51 单片机 LED 流水灯:从直接法到循环法(江科大课程笔记)
笔记·单片机·mongodb