mongodb - Invalid mongo configuration, either uri or host/port/credentials must be specified -


i'm getting exception :

caused by: java.lang.illegalstateexception: invalid mongo configuration, either uri or host/port/credentials must specified     @ org.springframework.boot.autoconfigure.mongo.mongoproperties.createmongoclient(mongoproperties.java:207)     @ org.springframework.boot.autoconfigure.mongo.mongoautoconfiguration.mongo(mongoautoconfiguration.java:73)     @ org.springframework.boot.autoconfigure.mongo.mongoautoconfiguration$$enhancerbyspringcglib$$15f9b896.cglib$mongo$1(<generated>)     @ org.springframework.boot.autoconfigure.mongo.mongoautoconfiguration$$enhancerbyspringcglib$$15f9b896$$fastclassbyspringcglib$$c0338f6a.invoke(<generated>)     @ org.springframework.cglib.proxy.methodproxy.invokesuper(methodproxy.java:228)     @ org.springframework.context.annotation.configurationclassenhancer$beanmethodinterceptor.intercept(configurationclassenhancer.java:356)     @ org.springframework.boot.autoconfigure.mongo.mongoautoconfiguration$$enhancerbyspringcglib$$15f9b896.mongo(<generated>)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:498)     @ org.springframework.beans.factory.support.simpleinstantiationstrategy.instantiate(simpleinstantiationstrategy.java:162)     ... 25 common frames omitted 

here application.yml content :

spring:   data:     mongodb:       uri: mongodb://develop:d3vel0p$@<my_host>:27017/sham 

here configuration class :

package com.me.service.testservice.config;  import com.mongodb.mongoclient; import org.springframework.context.annotation.bean; import org.springframework.context.annotation.configuration; import org.springframework.data.mongodb.core.mongotemplate; import org.springframework.data.mongodb.repository.config.enablemongorepositories;  @configuration @enablemongorepositories(basepackages = {"com.me.service.testservice.repository"}, considernestedrepositories = true) public class springmongoconfiguration {      @bean     public mongotemplate mongotemplate() throws exception {         return new mongotemplate(new mongoclient("<my_host>"), "sham");     } } 

now i'm getting stack trace when starting without failing, looks user develop doesn't have right connect:

caused by: com.mongodb.mongocommandexception: command failed error 18: 'authentication failed.' on server phelbwlabect003.karmalab.net:27017. full response { "ok" : 0.0, "errmsg" : "authentication failed.", "code" : 18, "codename" : "authenticationfailed" }     @ com.mongodb.connection.commandhelper.createcommandfailureexception(commandhelper.java:170)     @ com.mongodb.connection.commandhelper.receivecommandresult(commandhelper.java:123)     @ com.mongodb.connection.commandhelper.executecommand(commandhelper.java:32)     @ com.mongodb.connection.saslauthenticator.sendsaslstart(saslauthenticator.java:117)     @ com.mongodb.connection.saslauthenticator.access$000(saslauthenticator.java:37)     @ com.mongodb.connection.saslauthenticator$1.run(saslauthenticator.java:50)     ... 9 common frames omitted 

you mixing uri style connection settings individual properties style settings.

either use

spring:     data:         mongodb:             host: localhost             port: 27017             database: sham_test              username: develop             password: pass 

or

spring:     data:         mongodb:             uri:mongodb://develop:pass@localhost:27017/sham_test 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -