Advertisement

九、Spring Cloud Config Server详解(八):@RefreshScope自动刷新配置

阅读量:

9.9.手动刷新Config配置


若云端(我们采用gitee平台)的配置文件内容发生更新,而项目客户端尚未随之调整,此时应如何处理?

1、建立一个新的项目:将futurecloud-config-client-eureka项目进行复制,生成futurecloud-config-client-eureka-refresh项目
添加所需依赖:


复制代码
     <!--引入安全认证依赖-->
    <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-security</artifactId>
    <version>2.0.0.RELEASE</version>
    </dependency>
    
    

在后续进行post请求操作时,必须完成对eureka的登录验证过程


2、对controller类进行调整,添加@RefreshScope注解以启用配置更新功能

复制代码
    package com.futurecloud.controller;
    import org.springframework.beans.factory.

全部评论 (0)

还没有任何评论哟~