mongoProperties属性为null

时间:2016-09-02 06:09:20

标签: jhipster

我是Jhipster的新手。我用mongodb创建了网关项目。我在docker中启动了jhipster-registry和mongodb。没有其他微服务。当我调试网关项目时,我发现下面的错误:

Caused by: java.lang.IllegalArgumentException: Database name must not be empty
at org.springframework.util.Assert.hasText(Assert.java:168)
at org.springframework.data.mongodb.core.SimpleMongoDbFactory.<init>(SimpleMongoDbFactory.java:142)
at org.springframework.data.mongodb.core.SimpleMongoDbFactory.<init>(SimpleMongoDbFactory.java:93)
at org.springframework.data.mongodb.config.AbstractMongoConfiguration.mongoDbFactory(AbstractMongoConfiguration.java:114)
at com.xx.cloud.demo.config.DatabaseConfiguration$$EnhancerBySpringCGLIB$$65a29278.CGLIB$mongoDbFactory$6(<generated>)
at com.xx.cloud.demo.config.DatabaseConfiguration$$EnhancerBySpringCGLIB$$65a29278$$FastClassBySpringCGLIB$$7563f63.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356)
at com.xx.cloud.demo.config.DatabaseConfiguration$$EnhancerBySpringCGLIB$$65a29278.mongoDbFactory(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 182 common frames omitted

我在DatabaseConfiguration.java类的getDatabaseName()方法中设置了一个断点,并调试了getwayApp.java。我发现除了值为'mongodb:// localhost / test'的url之外,mongoProperties的所有属性都是null。我在application-dev.yml中配置了数据,如下所示:

data:
    cassandra:
        contactPoints: localhost
        protocolVersion: V4
        compression: LZ4
        keyspaceName: gateway
        repositories:
            enabled: false
        mongodb:
         host: localhost
         port: 27017
         uri: mongodb://localhost:27017
         database: jhipsterMongodbSampleApplication

但是我没有配置它的结果相同。

我应该如何以及在何处在网关中配置mongodb?提前谢谢。

1 个答案:

答案 0 :(得分:2)

您将mongodb块放在cassandra下,减少缩进。

另外,请不要忘记应在注册表中为应用程序定义应用程序属性,如部署。