authenticationDatabase

authenticationDatabase

本文介绍了验证无法通过Spring Boot进入mongoDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个服务器,以便我的网页/应用程序可以拨打电话,从现在开始,我要登录,因此,我已经根据需要创建了服务器,问题出在application.properties上,我想念的东西,我有这个:

I'm trying to create a server where my webpage / app can make calls, from now I'm starting with Login so, I've created the Server according my needs, the problem is on application.properties that I'm missing something, I have this :

spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.authentication-database=mydatabase
spring.data.mongodb.username=stuart
spring.data.mongodb.password=stuartdto
spring.data.mongodb.database=mydatabase

错误是尝试拨打登录电话时出现的错误

And the error is this one when trying to call the login call

我已使用此命令mongod --auth启动mongod,并创建了一个用户来执行此操作(之所以起作用,是因为如果我手动执行mongo -u user -p 'password' --authenticationDatabase "admin"则有效),直到我添加此所以也许这正是我从Spring中需要的.

I've started mongod using this command mongod --auth and I've created an user to do this (is working because if I do manually mongo -u user -p 'password' --authenticationDatabase "admin" works) it wasn't working until I add this --authenticationDatabase "admin" so maybe that's what I need from Spring.

我缺少什么?

推荐答案

当然,您说的是spring.data.mongodb.authentication-database = mydatabase,这是不正确的!

Of course, you are saying spring.data.mongodb.authentication-database = mydatabase and it's incorrect!

您想改用spring.data.mongodb.authentication-database = admin,它将起作用.

You want to use spring.data.mongodb.authentication-database = admin instead, and it will work.

这篇关于验证无法通过Spring Boot进入mongoDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 17:56