Mongobee MongoQueryException:没有经过身份验证的用户

时间:2018-11-15 04:24:14

标签: spring-data-mongodb mongobee

spring boot应用程序使用mongobee和mongodb,spring数据配置如下:

spring:
    data:
        mongodb:
            uri: mongodb://james:xxxxxxx@localhost:27017/?authSource=admin
            database: shortvideo

mongodb是由另一个docker容器创建和启动的,当我使用docker-compose和prod配置文件启动应用程序时,总是出现以下错误:

hdshortvideo-app_1_5c3629434c46 | 2018-11-15 02:21:36.924  WARN 1 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongobee' defined in class path resource [com/james/shortvideo/config/DatabaseConfiguration.class]: Invocation of init method failed; nested exception is com.mongodb.MongoQueryException: Query failed with error code 13 and error message 'there are no users authenticated' on server hdshortvideo-mongodb:27017
hdshortvideo-app_1_5c3629434c46 | 2018-11-15 02:21:36.936  INFO 1 --- [           main] c.j.s.config.CacheConfiguration          : Closing Cache Manager
hdshortvideo-mongodb_1_753bbfb0d5aa | 2018-11-15T02:21:36.966+0000 I ACCESS   [conn3] Unauthorized: not authorized on admin to execute command { endSessions: [ { id: UUID("4083d867-552a-4882-8b21-fd1c2f0de0f7") } ], $db: "admin", $readPreference: { mode: "primaryPreferred" } }
hdshortvideo-mongodb_1_753bbfb0d5aa | 2018-11-15T02:21:36.973+0000 I NETWORK  [conn3] end connection 172.25.0.3:60404 (2 connections now open)
hdshortvideo-mongodb_1_753bbfb0d5aa | 2018-11-15T02:21:36.974+0000 I NETWORK  [conn2] end connection 172.25.0.3:60398 (1 connection now open)
hdshortvideo-app_1_5c3629434c46 | 2018-11-15 02:21:36.975  INFO 1 --- [           main] com.netflix.discovery.DiscoveryClient    : Shutting down DiscoveryClient ...
hdshortvideo-app_1_5c3629434c46 | 2018-11-15 02:21:36.987  WARN 1 --- [           main] .s.c.a.CommonAnnotationBeanPostProcessor : Invocation of destroy method failed on bean with name 'scopedTarget.eurekaClient': org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'eurekaInstanceConfigBean': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
hdshortvideo-app_1_5c3629434c46 | 2018-11-15 02:21:37.023 ERROR 1 --- [           main] o.s.boot.SpringApplication               : Application run failed
hdshortvideo-app_1_5c3629434c46 |
hdshortvideo-app_1_5c3629434c46 | org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongobee' defined in class path resource [com/james/shortvideo/config/DatabaseConfiguration.class]: Invocation of init method failed; nested exception is com.mongodb.MongoQueryException: Query failed with error code 13 and error message 'there are no users authenticated' on server hdshortvideo-mongodb:27017
hdshortvideo-app_1_5c3629434c46 |       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1699)
hdshortvideo-app_1_5c3629434c46 |       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:573)
hdshortvideo-app_1_5c3629434c46 |       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)

当我使用shell连接到mongodb时,可以在其中找到用户“ james”:

> show users
{
        "_id" : "admin.james",
        "user" : "james",
        "db" : "admin",
        "roles" : [
                {
                        "role" : "root",
                        "db" : "admin"
                }
        ]
}

那么,“没有经过身份验证的用户意味着什么?我在Google上搜索了很多,但是没有运气,我现在被困住了。

0 个答案:

没有答案