mongoDb连接数据库配置报错Credentials need to specify username原因及解决方法

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘mongo-client’: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [com.mongodb.MongoCredential[]] for property ‘credentials’; nested exception is java.lang.IllegalArgumentException: Credentials need to specify username!
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [com.mongodb.MongoCredential[]] for property ‘credentials’; nested exception is java.lang.IllegalArgumentException: Credentials need to specify username!

完整的mongoDb配置信息如下,credentials包括三部分,用户名,密码,数据库名称,如果少写了@${mongo.dbname}就会报以上的错误信息


  
    
  
   
  
   
  
   

你可能感兴趣的:(JAVA基础)