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

相关推荐
Java内核笔记4 小时前
方法级 trace 看不出第几轮:给 Agent 补一层轮次维度
人工智能·spring boot·后端
2601_967987374 小时前
程序员遇到BUG的解释
程序员·bug·软件开发·调试·幽默
她的男孩4 小时前
转办给同事后对方一点同意就报幂等冲突:Forge Admin 不把转办键当成终态
spring boot·低代码·工作流引擎
jianqiang.xue5 小时前
线程一切换浮点全作废:五天修好的隐秘bug
bug
北风toto8 小时前
Spring Boot 常用注解 · 概要笔记
spring boot·笔记·后端
宋冠巡8 小时前
Spring Boot 4 + OpenTelemetry + Spring Cloud Gateway:全链路 TraceId 传播验证
spring boot·可观测性·traceid
下一站春风里8 小时前
Spring IoC 控制反转 完整技术笔记
java·spring boot·笔记·spring
小码哥0689 小时前
Spring Boot在线租房系统源码:UniApp找房、VR展示与预约管理落地解析
spring boot·租房小程序·租房系统·在线租房
芜名氏9 小时前
API 文档生成工具——SpringDoc
java·spring boot·ci/cd·设计规范
乌暮1 天前
Spring AOP 与 Spring 事务:用大白话彻底理解原理与实践
java·数据库·spring boot·后端·sql·学习·spring