在Git端修改配置后如何讓客戶端生效?
application.properties
中配置endpoints.restart.enabled=true啟動(dòng)指定的端口弊端: 通過(guò)restart耗時(shí)比較長(zhǎng),因此就有了RefreshScope
package com.lkl.springcloud.config.client;import org.springframework.beans.factory.annotation.Value;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.cloud.context.config.annotation.RefreshScope;import org.springframework.context.annotation.ComponentScan;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;/** * Created by liaokailin on 16/4/28. */@EnableAutoConfiguration@ComponentScan@RestController@RefreshScopepublic class Application { @Value("${name:World!}") String name ; @RequestMapping("/") public String home(){ return "Hello " + name; } public static void main(String[] args) { SpringApplication.run(Application.class,args); }}
聯(lián)系客服