为了账号安全,请及时绑定邮箱和手机立即绑定

spring boot连接mongodb报错

spring boot连接mongodb报错

富国沪深 2019-05-24 12:01:04
刚开始学习mongodb,编写了一个简单的springboot程序连接mongo,使用如下配置可以正确连接到mongo:spring.data.mongodb.host=10.159.14.19spring.data.mongodb.port=9001spring.data.mongodb.authentication-database=adminspring.data.mongodb.database=esignspring.data.mongodb.username=esign_writespring.data.mongodb.password=NTc2OTQ1YjcwN2Z但是使用下面的配置就会报错:spring.data.mongodb.uri=mongodb://esign_write:NTc2OTQ1YjcwN2Z@10.159.14.19:9001/esignspring.data.mongodb.authentication-database=admin错误信息如下:com.mongodb.MongoSecurityException:ExceptionauthenticatingMongoCredential{mechanism=null,userName='esign_write',source='esign',password=,mechanismProperties={}}atcom.mongodb.connection.SaslAuthenticator.authenticate(SaslAuthenticator.java:61)~[mongodb-driver-core-3.2.2.jar:na]atcom.mongodb.connection.DefaultAuthenticator.authenticate(DefaultAuthenticator.java:32)~[mongodb-driver-core-3.2.2.jar:na]atcom.mongodb.connection.InternalStreamConnectionInitializer.authenticateAll(InternalStreamConnectionInitializer.java:99)~[mongodb-driver-core-3.2.2.jar:na]atcom.mongodb.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:44)~[mongodb-driver-core-3.2.2.jar:na]atcom.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:115)~[mongodb-driver-core-3.2.2.jar:na]atcom.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:128)~[mongodb-driver-core-3.2.2.jar:na]atjava.lang.Thread.run(Thread.java:745)[na:1.8.0_121]Causedby:com.mongodb.MongoCommandException:Commandfailedwitherror18:'Authenticationfailed.'onserver10.159.14.19:9001.Thefullresponseis{"ok":0.0,"errmsg":"Authenticationfailed.","code":18,"codeName":"AuthenticationFailed"}atcom.mongodb.connection.CommandHelper.createCommandFailureException(CommandHelper.java:170)~[mongodb-driver-core-3.2.2.jar:na]atcom.mongodb.connection.CommandHelper.receiveCommandResult(CommandHelper.java:123)~[mongodb-driver-core-3.2.2.jar:na]atcom.mongodb.connection.CommandHelper.executeCommand(CommandHelper.java:32)~[mongodb-driver-core-3.2.2.jar:na]atcom.mongodb.connection.SaslAuthenticator.sendSaslStart(SaslAuthenticator.java:95)~[mongodb-driver-core-3.2.2.jar:na]atcom.mongodb.connection.SaslAuthenticator.authenticate(SaslAuthenticator.java:45)~[mongodb-driver-core-3.2.2.jar:na]...6commonframesomitted这个是什么原因?
查看完整描述

2 回答

?
MYYA

TA贡献1868条经验 获得超4个赞

spring.data.mongodb.uri=mongodb://esign_write:NTc2OTQ1YjcwN2Z@10.159.14.19:9001/esignspring.data.mongodb.authentication-database=admin改成spring.data.mongodb.uri=mongodb://esign_write:NTc2OTQ1YjcwN2Z@10.159.14.19:9001/spring.data.mongodb.database=esignspring.data.mongodb.authentication-database=admin
我也不知道为什么试了下可以
                            
查看完整回答
反对 回复 2019-05-24
  • 2 回答
  • 0 关注
  • 2029 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信