Mongobee MongoQueryException: нет аутентифицированных пользователей - PullRequest
0 голосов
/ 15 ноября 2018

приложение для весенней загрузки использует mongobee и mongodb, конфигурация данных о пружине выглядит следующим образом:

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

mongodb создается и запускается другим док-контейнером. Когда я запускаю приложение с профилем 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)

Когда я подключаюсь к mongodb с помощью shell, я могу найти там пользователя "james":

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

Так что, черт возьми, "нет аутентифицированных пользователей"? Я много гуглил, но не повезло, я застрял.

...