将spring boot微服务部署到heroku

问题描述 投票:4回答:1

我正在尝试将我的微服务部署到heroku,但没有成功。首先,我使用以下配置为服务注册表(eureka)创建了应用程序:

spring:
  application:
    name: eureka

server:
  port: 8761

eureka:
  instance:
    hostname: localhost
  client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

[下一步我部署应用程序,已部署应用程序的URL类似于https://eureka.herokuapp.com。我使用此URL配置其他应用程序,例如网关和业务服务。

我的网关配置示例

spring:
  application:
    name: gateway
server:
  port: 8081

eureka:
  client:
    healthcheck:
      enabled: true
    serviceUrl:
      defaultZone: https://eureka.herokuapp.com/eureka/

我用于用户服务的相同配置,只是不同的应用程序名称(用户服务)。当我转到https://gateway.herokuapp.com/user-service/user时,我不会收到任何回复。在网关应用程序的heroku日志中,由于用户服务超时,我无法看到异常,这是我不了解的,因为当我直接致电https://user.herokuapp.com/user时,我会得到响应

我还在我的尤里卡仪表板中发现没有注册的副本,我不确定是否可以。你能告诉我我做错了什么吗?谢谢。

enter image description here

来自网关应用程序的错误日志:

2019-12-01T19:53:29.503419 + 00:00 heroku [router]:at =信息方法= GET路径=“ /用户服务/用户” host = gateway.herokuapp.comrequest_id = 7818f5eb-34af-47f9-94db-7dc4f9609c31 fwd =“ 86.49.253.78”dyno = web.1 connect = 0ms服务= 8110ms状态= 500字节= 465协议= https

spring-boot heroku netflix-eureka netflix-zuul spring-cloud-netflix
1个回答
1
投票

您的网关配置缺少网关发现部分。另外注册表不需要“ serviceUrl”

尝试波纹管配置

注册表

spring:
  application:
    name: eureka

server:
  port: 8761

eureka:
  instance:
    prefer-ip-address: false
  client:
    register-with-eureka: false
    fetch-registry: false

网关

spring:
  application:
    name: gateway
  cloud:
    discovery:
      enabled: true 
    gateway:
      discovery:
        locator:
          enabled: true
          lower-case-service-id: true

server:
  port: 8081

eureka:
  client:
    fetch-registry: true
    register-with-eureka: true
    healthcheck:
      enabled: true
    serviceUrl:
      defaultZone: https://eureka.herokuapp.com/eureka/
© www.soinside.com 2019 - 2024. All rights reserved.