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.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.