【问题标题】:spring boot refresh the properties files without config serverspring boot 在没有配置服务器的情况下刷新属性文件
【发布时间】:2019-04-09 10:14:55
【问题描述】:

我想在spring boot中刷新属性文件。

版本 - 2.1.4.RELEASE

如果 spring 配置服务器必须将我的所有应用程序连接到我不想要的配置服务器,因为我们的应用程序处于生产状态并且我们不想要更大的变化。 是否有可能在同一个应用程序中我可以使用配置服务器刷新道具文件如果不使用配置服务器然后使用一些弹簧代码 我可以做吗。 不是 application.properties ,在项目之外有一个 application-optional.properties 只想刷新这个。

【问题讨论】:

    标签: spring-boot spring-boot-actuator


    【解决方案1】:

    RefreshEndpoint 由 Spring Cloud 提供。添加 spring cloud starter 配置将为您提供刷新所需的 bean 和 API。

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
    

    此外,您需要通过management.endpoints.web.exposure.include="health,info,refresh" 公开API,或者您可以使用"*" 将每个启用的执行器端点公开给网络。

    【讨论】:

    • 感谢您的回答。但是 spring-cloud-starter-config 需要一个 git repo 但我不需要它。我只有一个可选的属性文件,所以我只想刷新它。仅此而已。
    • 不,它不需要 git repo,Other sources are any JDBC compatible database, Subversion, Hashicorp Vault, Credhub and **local filesystems.** 您需要启动器提供的所有功能才能正确刷新属性,执行器 API 只是 一个一部分。
    • 对不起,但我不想使用 spring 配置服务器,因为必须将我的应用程序连接到 spring 配置服务器。我的项目之外只有一个可选的属性文件。只想重新加载调用一些的值获取方法。
    猜你喜欢
    • 2018-10-26
    • 2016-01-18
    • 2016-02-07
    • 1970-01-01
    • 2018-11-14
    • 2020-10-27
    • 2020-07-28
    • 2016-10-08
    • 2017-09-02
    相关资源
    最近更新 更多