gpt4 book ai didi

spring-boot - 将 spring boot 微服务部署到 heroku

转载 作者:行者123 更新时间:2023-12-04 02:59:46 24 4
gpt4 key购买 nike

我正在尝试将我的微服务部署到 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直接我得到回应

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

enter image description here

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

2019-12-01T19:53:29.503419+00:00 heroku[router]: at=info method=GET path="/user-service/user" host=gateway.herokuapp.com request_id=7818f5eb-34af-47f9-94db-7dc4f9609c31 fwd="86.49.253.78" dyno=web.1 connect=0ms service=8110ms status=500 bytes=465 protocol=https

最佳答案

您的网关配置缺少网关发现部分。注册表也不需要“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/

关于spring-boot - 将 spring boot 微服务部署到 heroku,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59129322/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com