Авторизация соединения JHipster MongoDB

У меня проблема с подключением сгенерированного JHipster приложения к защищенному экземпляру mongodb. Я создал пользователя mongodb для базы данных и предоставил ему роль readWrite.

> show users
{
    "_id" : "jhipster.jhipster",
    "user" : "jhipster",
    "db" : "jhipster",
    "roles" : [
        {
            "role" : "readWrite",
            "db" : "jhipster"
        }
    ]
}

В сгенерированном приложении я добавил настройки конфигурации файла application-dev.yml для mongodb следующим образом:

server:
    port: 8080

spring:
    profiles:
        active: dev
    data:
        mongodb:
            host: localhost
            port: 27017
            database: jhipster
            authenticationDatabase: jhipster
            username: jhipster
            password: jhipster

    mail:
        baseUrl: http://localhost:8080

    thymeleaf:
        mode: XHTML
        cache: false

metrics:
    jmx.enabled: true
    spark:
        enabled: false
        host: localhost
        port: 9999
    graphite:
        enabled: false
        host: localhost
        port: 2003
        prefix: jhipster

После запуска приложения командой mvn spring-boot:run я получаю следующую трассировку стека:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building jhipster 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> spring-boot-maven-plugin:1.2.1.RELEASE:run (default-cli) > test-compile @ jhipster >>>
[INFO] 
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-versions) @ jhipster ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jhipster ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] Copying 8 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jhipster ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 82 source files to /Users/grega/Development/sandbox/jhipster/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ jhipster ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ jhipster ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] <<< spring-boot-maven-plugin:1.2.1.RELEASE:run (default-cli) < test-compile @ jhipster <<<
[INFO] 
[INFO] --- spring-boot-maven-plugin:1.2.1.RELEASE:run (default-cli) @ jhipster ---
[INFO] Attaching agents: []
Listening for transport dt_socket at address: 5005
[INFO] com.mycompany.myapp.Application - Starting Application on Gregas-MacBook-Pro.local with PID 20096 (/Users/grega/Development/sandbox/jhipster/target/classes started by grega in /Users/grega/Development/sandbox/jhipster)
[DEBUG] com.mycompany.myapp.Application - Running with Spring Boot v1.2.1.RELEASE, Spring v4.1.4.RELEASE
[DEBUG] org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
[DEBUG] com.mycompany.myapp.config.AsyncConfiguration - Creating Async Task Executor
[DEBUG] com.mycompany.myapp.config.MetricsConfiguration - Registering JVM gauges
[INFO] com.mycompany.myapp.config.MetricsConfiguration - Initializing Metrics JMX reporting
[DEBUG] com.mycompany.myapp.config.MailConfiguration - Configuring mail server
[INFO] com.mycompany.myapp.config.WebConfigurer - Web application configuration, using profiles: [dev]
[DEBUG] com.mycompany.myapp.config.WebConfigurer - Initializing Metrics registries
[DEBUG] com.mycompany.myapp.config.WebConfigurer - Registering Metrics Filter
[DEBUG] com.mycompany.myapp.config.WebConfigurer - Registering Metrics Servlet
[INFO] com.mycompany.myapp.config.WebConfigurer - Web application fully configured
[INFO] com.mycompany.myapp.Application - Running with Spring profile(s) : [dev]
[INFO] com.mycompany.myapp.config.ThymeleafConfiguration - loading non-reloadable mail messages resources
[DEBUG] com.mycompany.myapp.config.apidoc.SwaggerConfiguration - Starting Swagger
[DEBUG] com.mycompany.myapp.config.apidoc.SwaggerConfiguration - Started Swagger in 34 ms
[DEBUG] com.mycompany.myapp.config.CacheConfiguration - No cache
[DEBUG] com.mycompany.myapp.config.DatabaseConfiguration - Configuring Mongeez
[INFO] org.mongeez.reader.FilesetXMLReader - Num of changefiles 2
[WARN] org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongeez' defined in class path resource [com/mycompany/myapp/config/DatabaseConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.mongeez.Mongeez]: Factory method 'mongeez' threw exception; nested exception is com.mongodb.CommandFailureException: { "serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "not authorized on jhipster to execute command { $eval: \"db.T_AUTHORITY.insert({\"_id\" : \"ROLE_ADMIN\"});\n            db.T_AUTHORITY.insert({\"_id\" : \"ROLE_USER\"});\", args: [] }" , "code" : 13}
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1111) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1006) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) ~[spring-context-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) ~[spring-context-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) [spring-boot-1.2.1.RELEASE.jar:1.2.1.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691) [spring-boot-1.2.1.RELEASE.jar:1.2.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) [spring-boot-1.2.1.RELEASE.jar:1.2.1.RELEASE]
    at com.mycompany.myapp.Application.main(Application.java:55) [classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.mongeez.Mongeez]: Factory method 'mongeez' threw exception; nested exception is com.mongodb.CommandFailureException: { "serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "not authorized on jhipster to execute command { $eval: \"db.T_AUTHORITY.insert({\"_id\" : \"ROLE_ADMIN\"});\n            db.T_AUTHORITY.insert({\"_id\" : \"ROLE_USER\"});\", args: [] }" , "code" : 13}
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    ... 15 common frames omitted
Caused by: com.mongodb.CommandFailureException: { "serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "not authorized on jhipster to execute command { $eval: \"db.T_AUTHORITY.insert({\"_id\" : \"ROLE_ADMIN\"});\n            db.T_AUTHORITY.insert({\"_id\" : \"ROLE_USER\"});\", args: [] }" , "code" : 13}
    at com.mongodb.CommandResult.getException(CommandResult.java:76) ~[mongo-java-driver-2.12.4.jar:na]
    at com.mongodb.CommandResult.throwOnError(CommandResult.java:131) ~[mongo-java-driver-2.12.4.jar:na]
    at com.mongodb.DB.eval(DB.java:461) ~[mongo-java-driver-2.12.4.jar:na]
    at org.mongeez.dao.MongeezDao.runScript(MongeezDao.java:124) ~[mongeez-0.9.4.jar:na]
    at org.mongeez.commands.Script.run(Script.java:32) ~[mongeez-0.9.4.jar:na]
    at org.mongeez.ChangeSetExecutor.execute(ChangeSetExecutor.java:53) ~[mongeez-0.9.4.jar:na]
    at org.mongeez.ChangeSetExecutor.execute(ChangeSetExecutor.java:42) ~[mongeez-0.9.4.jar:na]
    at org.mongeez.Mongeez.process(Mongeez.java:40) ~[mongeez-0.9.4.jar:na]
    at com.mycompany.myapp.config.DatabaseConfiguration.mongeez(DatabaseConfiguration.java:65) ~[classes/:na]
    at com.mycompany.myapp.config.DatabaseConfiguration$$EnhancerBySpringCGLIB$$5c5942c3.CGLIB$mongeez$4(<generated>) ~[spring-core-4.1.4.RELEASE.jar:na]
    at com.mycompany.myapp.config.DatabaseConfiguration$$EnhancerBySpringCGLIB$$5c5942c3$$FastClassBySpringCGLIB$$e5d33dc7.invoke(<generated>) ~[spring-core-4.1.4.RELEASE.jar:na]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309) ~[spring-context-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at com.mycompany.myapp.config.DatabaseConfiguration$$EnhancerBySpringCGLIB$$5c5942c3.mongeez(<generated>) ~[spring-core-4.1.4.RELEASE.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_65]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_65]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_65]
    at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_65]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    ... 16 common frames omitted
[INFO] com.mycompany.myapp.config.CacheConfiguration - Closing Cache Manager
[ERROR] org.springframework.boot.SpringApplication - Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongeez' defined in class path resource [com/mycompany/myapp/config/DatabaseConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.mongeez.Mongeez]: Factory method 'mongeez' threw exception; nested exception is com.mongodb.CommandFailureException: { "serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "not authorized on jhipster to execute command { $eval: \"db.T_AUTHORITY.insert({\"_id\" : \"ROLE_ADMIN\"});\n            db.T_AUTHORITY.insert({\"_id\" : \"ROLE_USER\"});\", args: [] }" , "code" : 13}
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1111) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1006) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) ~[spring-context-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) ~[spring-context-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.2.1.RELEASE.jar:1.2.1.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691) ~[spring-boot-1.2.1.RELEASE.jar:1.2.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) ~[spring-boot-1.2.1.RELEASE.jar:1.2.1.RELEASE]
    at com.mycompany.myapp.Application.main(Application.java:55) [classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.mongeez.Mongeez]: Factory method 'mongeez' threw exception; nested exception is com.mongodb.CommandFailureException: { "serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "not authorized on jhipster to execute command { $eval: \"db.T_AUTHORITY.insert({\"_id\" : \"ROLE_ADMIN\"});\n            db.T_AUTHORITY.insert({\"_id\" : \"ROLE_USER\"});\", args: [] }" , "code" : 13}
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    ... 15 common frames omitted
Caused by: com.mongodb.CommandFailureException: { "serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "not authorized on jhipster to execute command { $eval: \"db.T_AUTHORITY.insert({\"_id\" : \"ROLE_ADMIN\"});\n            db.T_AUTHORITY.insert({\"_id\" : \"ROLE_USER\"});\", args: [] }" , "code" : 13}
    at com.mongodb.CommandResult.getException(CommandResult.java:76) ~[mongo-java-driver-2.12.4.jar:na]
    at com.mongodb.CommandResult.throwOnError(CommandResult.java:131) ~[mongo-java-driver-2.12.4.jar:na]
    at com.mongodb.DB.eval(DB.java:461) ~[mongo-java-driver-2.12.4.jar:na]
    at org.mongeez.dao.MongeezDao.runScript(MongeezDao.java:124) ~[mongeez-0.9.4.jar:na]
    at org.mongeez.commands.Script.run(Script.java:32) ~[mongeez-0.9.4.jar:na]
    at org.mongeez.ChangeSetExecutor.execute(ChangeSetExecutor.java:53) ~[mongeez-0.9.4.jar:na]
    at org.mongeez.ChangeSetExecutor.execute(ChangeSetExecutor.java:42) ~[mongeez-0.9.4.jar:na]
    at org.mongeez.Mongeez.process(Mongeez.java:40) ~[mongeez-0.9.4.jar:na]
    at com.mycompany.myapp.config.DatabaseConfiguration.mongeez(DatabaseConfiguration.java:65) ~[classes/:na]
    at com.mycompany.myapp.config.DatabaseConfiguration$$EnhancerBySpringCGLIB$$5c5942c3.CGLIB$mongeez$4(<generated>) ~[spring-core-4.1.4.RELEASE.jar:na]
    at com.mycompany.myapp.config.DatabaseConfiguration$$EnhancerBySpringCGLIB$$5c5942c3$$FastClassBySpringCGLIB$$e5d33dc7.invoke(<generated>) ~[spring-core-4.1.4.RELEASE.jar:na]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309) ~[spring-context-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at com.mycompany.myapp.config.DatabaseConfiguration$$EnhancerBySpringCGLIB$$5c5942c3.mongeez(<generated>) ~[spring-core-4.1.4.RELEASE.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_65]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_65]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_65]
    at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_65]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    ... 16 common frames omitted
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongeez' defined in class path resource [com/mycompany/myapp/config/DatabaseConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.mongeez.Mongeez]: Factory method 'mongeez' threw exception; nested exception is com.mongodb.CommandFailureException: { "serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "not authorized on jhipster to execute command { $eval: \"db.T_AUTHORITY.insert({\"_id\" : \"ROLE_ADMIN\"});\n            db.T_AUTHORITY.insert({\"_id\" : \"ROLE_USER\"});\", args: [] }" , "code" : 13}
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1111)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1006)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
    at com.mycompany.myapp.Application.main(Application.java:55)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.mongeez.Mongeez]: Factory method 'mongeez' threw exception; nested exception is com.mongodb.CommandFailureException: { "serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "not authorized on jhipster to execute command { $eval: \"db.T_AUTHORITY.insert({\"_id\" : \"ROLE_ADMIN\"});\n            db.T_AUTHORITY.insert({\"_id\" : \"ROLE_USER\"});\", args: [] }" , "code" : 13}
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
    ... 15 more
Caused by: com.mongodb.CommandFailureException: { "serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "not authorized on jhipster to execute command { $eval: \"db.T_AUTHORITY.insert({\"_id\" : \"ROLE_ADMIN\"});\n            db.T_AUTHORITY.insert({\"_id\" : \"ROLE_USER\"});\", args: [] }" , "code" : 13}
    at com.mongodb.CommandResult.getException(CommandResult.java:76)
    at com.mongodb.CommandResult.throwOnError(CommandResult.java:131)
    at com.mongodb.DB.eval(DB.java:461)
    at org.mongeez.dao.MongeezDao.runScript(MongeezDao.java:124)
    at org.mongeez.commands.Script.run(Script.java:32)
    at org.mongeez.ChangeSetExecutor.execute(ChangeSetExecutor.java:53)
    at org.mongeez.ChangeSetExecutor.execute(ChangeSetExecutor.java:42)
    at org.mongeez.Mongeez.process(Mongeez.java:40)
    at com.mycompany.myapp.config.DatabaseConfiguration.mongeez(DatabaseConfiguration.java:65)
    at com.mycompany.myapp.config.DatabaseConfiguration$$EnhancerBySpringCGLIB$$5c5942c3.CGLIB$mongeez$4(<generated>)
    at com.mycompany.myapp.config.DatabaseConfiguration$$EnhancerBySpringCGLIB$$5c5942c3$$FastClassBySpringCGLIB$$e5d33dc7.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309)
    at com.mycompany.myapp.config.DatabaseConfiguration$$EnhancerBySpringCGLIB$$5c5942c3.mongeez(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
    ... 16 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.800 s
[INFO] Finished at: 2015-02-13T18:56:39+01:00
[INFO] Final Memory: 28M/228M
[INFO] ------------------------------------------------------------------------

Кто-нибудь знает, что я делаю неправильно?


person Greg    schedule 13.02.2015    source источник


Ответы (5)


У меня была такая же проблема в течение дня.

Я до сих пор не знаю настоящую причину моей проблемы (у меня был тот же стек ошибок), но я отключил SELinux, и это сработало. (Хотя у меня не было никаких уведомлений от SELinux)

Вы должны выглядеть так!

Удачи

person Christo G    schedule 11.03.2015

Я не уверен, почему это не работает, поскольку я все еще сталкиваюсь с той же проблемой, но с использованием следующих свойств работают

spring.data.mongodb.uri=mongodb://имя пользователя:пароль@localhost:27017/имя_базы_данных

person zdesam    schedule 08.07.2018

У меня была такая же проблема вчера. Проблема в том, что MongoDB 3.0 изменил механизм аутентификации по умолчанию с MONGODB-CR на SCRAM-SHA-1.

Попробуйте это (у меня сработало):

1) Обновите до последней версии Spring Data Mongodb Добавьте в свойства pom.xml это:

<spring-data-releasetrain.version>Fowler-SR2</spring-data-releasetrain.version>

2) Добавьте последнюю версию mongo-java-драйвера

<dependency>
       <groupId>org.mongodb</groupId>
       <artifactId>mongo-java-driver</artifactId>
       <version>3.0.4</version>
</dependency>

3) Установите специальные параметры MongoClient для настройки учетных данных.

Override
    @Bean
    public Mongo mongo() throws Exception {
        return new MongoClient(singletonList(new ServerAddress(host, port)),
                singletonList(MongoCredential.createCredential(username,database, password.toCharArray())));
    }

Если вам нужна дополнительная информация, я написал об этом подробный пост: http://ignaciosuay.com/how-to-connect-to-mongodb-3-0-using-spring-boot/

person ignacio.suay    schedule 08.10.2015

Mongeez использует команду mongodb eval для начальной загрузки базы данных. В некоторых сценариях эта команда не разрешена/отключена. Поэтому Mongeez не подойдет.

Вместо Mongeez вы можете использовать mongobee чтобы предоставить логику миграции для вашего приложения.

Это мой код миграции mongobee по умолчанию для jhipster, который имеет тот же эффект, что и код mongeez.

package your.package.name.config.dbmigrations;

import com.github.mongobee.changeset.ChangeLog;
import com.github.mongobee.changeset.ChangeSet;
import com.mongodb.BasicDBObjectBuilder;
import com.mongodb.DB;
import com.mongodb.DBCollection;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Creates the initial database setup
 */
@ChangeLog(order = "001")
public class InitialSetupMigration {


    private Map<String, String>[] authoritiesUser = new Map[]{new HashMap<>()};

    private Map<String, String>[] authoritiesAdminAndUser = new Map[]{new HashMap<>(), new HashMap<>()};

    {
        authoritiesUser[0].put("_id", "ROLE_USER");

        authoritiesAdminAndUser[0].put("_id", "ROLE_USER");
        authoritiesAdminAndUser[1].put("_id", "ROLE_ADMIN");
    }

    @ChangeSet(order = "01", author = "initiator", id = "01-addAuthorities")
    public void addAuthorities(DB db) {
        DBCollection authorityCollection = db.getCollection("jhi_authority");
        authorityCollection.insert(
            BasicDBObjectBuilder.start()
                .add("_id", "ROLE_ADMIN")
                .get());
        authorityCollection.insert(
            BasicDBObjectBuilder.start()
                .add("_id", "ROLE_USER")
                .get());
    }


    @ChangeSet(order = "02", author = "initiator", id = "02-addUsers")
    public void addUsers(DB db) {
        DBCollection usersCollection = db.getCollection("jhi_user");
        usersCollection.createIndex("login");
        usersCollection.createIndex("email");
        usersCollection.insert(BasicDBObjectBuilder.start()
            .add("_id", "user-0")
            .add("login", "system")
            .add("password", "$2a$10$mE.qmcV0mFU5NcKh73TZx.z4ueI/.bDWbj0T1BYyqP481kGGarKLG")
            .add("first_name", "")
            .add("last_name", "System")
            .add("email", "system@localhost")
            .add("activated", "true")
            .add("lang_key", "en")
            .add("created_by", "system")
            .add("created_date", new Date())
            .add("authorities", authoritiesAdminAndUser)
            .get()
        );
        usersCollection.insert(BasicDBObjectBuilder.start()
            .add("_id", "user-1")
            .add("login", "anonymousUser")
            .add("password", "$2a$10$j8S5d7Sr7.8VTOYNviDPOeWX8KcYILUVJBsYV83Y5NtECayypx9lO")
            .add("first_name", "Anonymous")
            .add("last_name", "User")
            .add("email", "anonymous@localhost")
            .add("activated", "true")
            .add("lang_key", "en")
            .add("created_by", "system")
            .add("created_date", new Date())
            .add("authorities", new Map[]{})
            .get()
        );
        usersCollection.insert(BasicDBObjectBuilder.start()
            .add("_id", "user-2")
            .add("login", "admin")
            .add("password", "$2a$10$gSAhZrxMllrbgj/kkK9UceBPpChGWJA7SYIb1Mqo.n5aNLq1/oRrC")
            .add("first_name", "admin")
            .add("last_name", "Administrator")
            .add("email", "admin@localhost")
            .add("activated", "true")
            .add("lang_key", "en")
            .add("created_by", "system")
            .add("created_date", new Date())
            .add("authorities", authoritiesAdminAndUser)
            .get()
        );
        usersCollection.insert(BasicDBObjectBuilder.start()
            .add("_id", "user-3")
            .add("login", "user")
            .add("password", "$2a$10$VEjxo0jq2YG9Rbk2HmX9S.k1uZBGYUHdUcid3g/vfiEl7lwWgOH/K")
            .add("first_name", "")
            .add("last_name", "User")
            .add("email", "user@localhost")
            .add("activated", "true")
            .add("lang_key", "en")
            .add("created_by", "system")
            .add("created_date", new Date())
            .add("authorities", authoritiesUser)
            .get()
        );
    }

    @ChangeSet(author = "initiator", id = "03-addSocialUserConnection", order = "03")
    public void addSocialUserConnection(DB db) {
        DBCollection socialUserConnectionCollection = db.getCollection("jhi_social_user_connection");
        socialUserConnectionCollection.createIndex(BasicDBObjectBuilder
                .start("user_id", 1)
                .add("provider_id", 1)
                .add("provider_user_id", 1)
                .get(),
            "user-prov-provusr-idx", true);
    }
}

В файле DatabaseConfiguration.java удалите mongeez и добавьте

@Bean
public Mongobee mongobee() {

    log.debug("Configuring Mongobee");

    Mongobee mongobee = new Mongobee(mongo);
    mongobee.setDbName(mongoProperties.getDatabase());
    mongobee.setChangeLogsScanPackage(
        "de.shaere.sharecore.config.dbmigrations"); // package to scan for changesets
    mongobee.setEnabled(true);
    return mongobee;
}

И, наконец, обновите файл gradle, удалив зависимость от mongeez и добавив:

compile group: 'com.github.mongobee', name: 'mongobee', version: mongobee_version

Я также открыл запрос на включение для обновления генератора JHipster. Теперь ждем, согласятся ли ребята :)

person Matyas    schedule 27.04.2016

Зашифрованный пароль по умолчанию, упомянутый в классе InitialSetupMigration, неверен.

Измененные учетные данные будут

имя пользователя: пароль администратора: пользователь

person Nitin Jha    schedule 08.01.2021