首页 文章

没有Eureka,Ribbon和spring boot的Spring cloud配置客户端

提问于
浏览
0

我在AWS中运行了spring web应用程序(不是spring boot) . 我正在尝试创建集中配置服务器 . 如何在更改属性后刷新spring-cloud-client?根据教程

Actuator endpoints 通过向客户端的刷新 endpoints 发送空HTTP POST,http:// localhost:8080 / refresh,然后通过查看http:// localhost:8080 / message endpoints 确认它是否有效 .

但我的ecs Ec2实例是负载均衡器的后面,所以我无法调用客户端URL . 我不太了解netflix Eureka和Ribbon,但似乎在客户端增加了另一级负载均衡器 . 我不喜欢这种方法 . 只是为了改变一个属性,我不想让现有项目变得不必要地复杂 . 还有其他方法吗?还是我误解了Eureka / Ribbon的用法?

我看了spring-cloud-config-client-without-spring-bootspring-cloud-config-client-without-auto-configuration没有人回答 . 2015年回答了第一个帖子 . 想知道有没有更新?

1 回答

  • 1

    从配置服务器获取配置属性 . 你可以做一个http请求 . 例:

    从文档中我们可以看到:

    /{application}/{profile}[/{label}]
    /{application}-{profile}.yml <- example
    /{label}/{application}-{profile}.yml
    /{application}-{profile}.properties
    /{label}/{application}-{profile}.properties
    

    因此,如果您要向 http://localhost:8080/applicationName-activeProfile.yml 发出请求,您将收到具有该名称和活动配置文件的应用程序的.yml格式的属性 . Spring启动配置客户端会自动提供这些值,但您必须手动提供em .

    你不是一个单独的组件 . 更多信息:http://cloud.spring.io/spring-cloud-static/spring-cloud.html#_spring_cloud_config

    也许你甚至可以使用spring-cloud-config,但我不确定没有spring-boot需要什么额外的配置 . https://cloud.spring.io/spring-cloud-config/

相关问题