首页 文章资讯内容详情

springboot集成mongoDB需要认证

2026-05-31 4 花语

本文内容纲要:

报错:

MonNov2501:09:48CST2019

Therewasanunexpectederror(type=InternalServerError,status=500).

Commandfailedwitherror13(Unauthorized):commandupdaterequiresauthenticationonserver192.168.180.113:27017.Thefullresponseis{"ok":0.0,"errmsg":"commandupdaterequiresauthentication","code":13,"codeName":"Unauthorized"};nestedexceptioniscom.mongodb.MongoCommandException:Commandfailedwitherror13(Unauthorized):commandupdaterequiresauthenticationonserver192.168.180.113:27017.Thefullresponseis{"ok":0.0,"errmsg":"commandupdaterequiresauthentication","code":13,"codeName":"Unauthorized"}

org.springframework.data.mongodb.UncategorizedMongoDbException:Commandfailedwitherror13(Unauthorized):commandupdaterequiresauthenticationonserver192.168.180.113:27017.Thefullresponseis{"ok":0.0,"errmsg":"commandupdaterequiresauthentication","code":13,"codeName":"Unauthorized"};nestedexceptioniscom.mongodb.MongoCommandException:Commandfailedwitherror13(Unauthorized):commandupdaterequiresauthenticationonserver192.168.180.113:27017.Thefullresponseis{"ok":0.0,"errmsg":"commandupdaterequiresauthentication","code":13,"codeName":"Unauthorized"}

报错的配置:

spring: application: name:spring-boot-mongodb data: mongodb: username:test password:123456 uri:mongodb://192.168.180.113:27017/test

解决:

spring: application: name:spring-boot-mongodb data: mongodb: uri:mongodb://test:123456@192.168.180.113:27017/test

本文内容总结:

原文链接:https://www.cnblogs.com/dalianpai/p/11925480.html