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

相关推荐
立心者010 小时前
SpringBoot中使用TOTP实现MFA(多因素认证)
java·spring boot·后端
西门啐血14 小时前
上位机开发之假装有设备,使用 C# 模拟串口设备
开发语言·mongodb·c#
QQ_216962909614 小时前
Spring Boot 养老院管理系统:从入住、护理到费用结算的全流程实现(源码可领)
java·spring boot·后端
xxwl58518 小时前
数据库后端接口测试报告
spring boot·mysql·tomcat
zzzzzz31018 小时前
别让大模型直接碰业务:我在 Spring Boot 里给 AI 操作加了一道“可拒绝的闸门”
人工智能·spring boot·spring
知彼解己18 小时前
Java 版本演进
java·开发语言·spring boot
夜郎king18 小时前
SpringBoot+PostgreSQL + 硅基流动大模型从零搭建 Text-to-SQL 智能问答系统
spring boot·postgresql·text-to-sql·llm大模型
蓝天下的守望者19 小时前
验证环境中使用队列的pop_front()思维惯性引发的bug
bug
就改了20 小时前
MyBatis核心类用法详解
java·spring boot·后端·mybatis
DarLing丶张皇20 小时前
【源码】JeecgBoot导出Excel模板
java·spring boot