Browse Source

客户端通过/refresh请求在线更新配置

gengzibing 6 years ago
parent
commit
0906826950

+ 5 - 0
pom.xml

@@ -40,6 +40,11 @@
 			<groupId>org.springframework.cloud</groupId>
 			<artifactId>spring-cloud-starter-config</artifactId>
 		</dependency>
+
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-actuator</artifactId>
+		</dependency>
 	</dependencies>
 
 	<dependencyManagement>

+ 2 - 0
src/main/java/com/njty/eurekaclient/controller/HelloController.java

@@ -1,11 +1,13 @@
 package com.njty.eurekaclient.controller;
 
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.stereotype.Component;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+@RefreshScope
 @RestController
 @RequestMapping("/hello")
 public class HelloController {

+ 4 - 1
src/main/resources/application.yml

@@ -8,4 +8,7 @@ spring:
     application:
         name: eurekaclient
 
-helloConfig: this is local
+helloConfig: this is local
+management:
+  security:
+    enabled: false