欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

@RefreshScope 自動刷新配置文件的實例講解

 更新時間:2022年11月07日 11:37:43   作者:抓手  
efreshScope(org.springframework.cloud.context.scope.refresh)是spring cloud提供的一種特殊的scope實現(xiàn),用來實現(xiàn)配置、實例熱加載,這篇文章主要介紹了@RefreshScope 自動刷新配置文件,需要的朋友可以參考下

1.在類上加@RefreshScope注解。

2.引入配置@Value。

/**
 * @author 向振華
 * @date 2018/12/17 17:20
 */
@RefreshScope //配置文件自動刷新
@RestController
@RequestMapping("test")
public class TestController {
 
    @Value("${test.xzh}") //引入配置
    private String xzh;
 
    @RequestMapping("/test1")
    public String test1(){
        return xzh;
    }
 
}

3.配置文件

#配置
test.xzh=xiangzhenhua
 
#動態(tài)刷新配置 ---需要忽略權(quán)限攔截
management.security.enabled=false

4.git配置webhooks,也可手動發(fā)送POST請求 http://localhost:1003/refresh

PS:在Spring Boot升級到2.0.3.RELEASE后需新增配置

management.endpoints.web.exposure.include=refresh

此時刷新配置文件url為:http://localhost:1003/actuator/refresh

到此這篇關于@RefreshScope 自動刷新配置文件的文章就介紹到這了,更多相關@RefreshScope 配置文件自動刷新內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

最新評論