Spring Cloud构建微服务架构(四)分布式配置中心
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package com.didispace;
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new SpringApplicationBuilder(Application.class).web(true).run(args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.didispace.web;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RefreshScope
|
||||
@RestController
|
||||
class TestController {
|
||||
|
||||
@Value("${from}")
|
||||
private String from;
|
||||
|
||||
@RequestMapping("/from")
|
||||
public String from() {
|
||||
|
||||
return this.from;
|
||||
}
|
||||
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
spring.application.name=didispace
|
||||
spring.cloud.config.profile=dev
|
||||
spring.cloud.config.uri=http://localhost:7001/
|
||||
|
||||
server.port=7002
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user