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

相关推荐
今天的砖头有点烫手啊2 小时前
接口太慢?Spring Boot 缓存体系 @Cacheable 全链路拆解
spring boot·后端·缓存
zzzll11114 小时前
Spring Boot 入门指南:从零开始构建微服务
spring boot·后端·微服务
用户3126874877204 小时前
你的定时任务真的靠谱吗?Spring Boot @Scheduled 全链路拆解
spring boot
程序员天天困5 小时前
Spring Boot i18n 国际化实战:从资源文件到多语言接口完整指南
spring boot·后端·编程语言
Flittly1 天前
【雕虫大技】Agent 动态 Skill 供应链安全加固(二):执行隔离沙箱实战
java·spring boot·spring
沐言人生1 天前
HelloAgentR工程手记1/100天——项目工作流搭建
spring boot·agent·vibecoding
陌上丨1 天前
Spring Boot 应用类型推断机制:一次从源码到原理的深度探索
java·spring boot·后端
云烟成雨TD1 天前
Micrometer 系列【33】Spring Boot Micrometer Metrics 自动配置模块解析
spring boot·云原生·micrometer
吨吨ai1 天前
# ChatGPT Plus / Pro + Codex Debug 实战:如何让 AI 从日志、Trace、异常堆栈自动定位线上 Bug
人工智能·chatgpt·bug
用户3126874877201 天前
接口太慢?Spring Boot 缓存体系 @Cacheable 全链路拆解
spring boot