用consul启动jHipster微服务时出错

时间:2017-02-22 09:07:01

标签: spring-boot spring-cloud jhipster consul

我正在尝试使用此tutorial构建示例微服务应用。 Jhipster版本是4.0.6 所以我使用这个命令创建了网关,服务并启动了领事:

docker-compose -f src/main/docker/consul.yml up

来自我的网关目录。 但是在Spring Boot启动时出现错误,这是日志:

2017-02-22 11:52:25.679 ERROR 3168 --- [  restartedMain] o.s.c.c.c.ConsulPropertySourceLocator    : Fail fast is set and there was an error reading configuration from consul.

2017-02-22 11:52:32.491  WARN 3168 --- [  restartedMain] o.s.boot.SpringApplication               : Error handling failed (ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2a5b2096: startup date [Thu Jan 01 03:00:00 AST 1970]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@5108df79)
com.ecwid.consul.transport.TransportException: java.net.ConnectException: Connection refused: connect

你能帮忙解决这个问题吗?

更新: 我发现应用尝试在staptup上对URL进行GET请求:

http://localhost:8500/v1/kv/config/armory,dev/?recurse&token=

但Consul K / V存储中存储的唯一数据是:

KEY: config/application/data

VALUE:
configserver:
    name: Docker Consul Service
    status: Connected to Consul Server running in Docker

jhipster:
    security:
        authentication:
            jwt:
                secret: my-secret-token-to-change-in-production

1 个答案:

答案 0 :(得分:3)

如果consul在dev配置文件中运行,或者如果consul在prod配置文件中运行,则必须将应用程序yaml配置复制到consul实例as explained in the doccentral-server-config目录。

因此,假设您的应用被命名为“军械库”,则应将src/main/resources/config/application.yml复制到armory.yml以及每个配置文件(例如application-dev.ymlarmory-dev.yml