diff --git a/Chapter9-1-4/config-client/pom.xml b/Chapter9-1-4/config-client/pom.xml new file mode 100644 index 0000000..5cfdb39 --- /dev/null +++ b/Chapter9-1-4/config-client/pom.xml @@ -0,0 +1,67 @@ + + + 4.0.0 + + com.didispace + config-client + 1.0.0 + jar + + config-client + Spring Cloud project + + + org.springframework.boot + spring-boot-starter-parent + 1.3.5.RELEASE + + + + + UTF-8 + 1.8 + + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.cloud + spring-cloud-starter-config + + + + + + + + org.springframework.cloud + spring-cloud-dependencies + Brixton.RELEASE + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + \ No newline at end of file diff --git a/Chapter9-1-4/config-client/src/main/java/com/didispace/Application.java b/Chapter9-1-4/config-client/src/main/java/com/didispace/Application.java new file mode 100644 index 0000000..d956eaf --- /dev/null +++ b/Chapter9-1-4/config-client/src/main/java/com/didispace/Application.java @@ -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); + } + +} diff --git a/Chapter9-1-4/config-client/src/main/java/com/didispace/web/TestController.java b/Chapter9-1-4/config-client/src/main/java/com/didispace/web/TestController.java new file mode 100644 index 0000000..f8b8095 --- /dev/null +++ b/Chapter9-1-4/config-client/src/main/java/com/didispace/web/TestController.java @@ -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; + } + +} \ No newline at end of file diff --git a/Chapter9-1-4/config-client/src/main/resources/bootstrap.properties b/Chapter9-1-4/config-client/src/main/resources/bootstrap.properties new file mode 100644 index 0000000..f42ca34 --- /dev/null +++ b/Chapter9-1-4/config-client/src/main/resources/bootstrap.properties @@ -0,0 +1,10 @@ +spring.application.name=didispace +spring.cloud.config.profile=dev +spring.cloud.config.uri=http://localhost:7001/ + +server.port=7002 + + + + + diff --git a/Chapter9-1-4/config-repo/didispace-dev.properties b/Chapter9-1-4/config-repo/didispace-dev.properties index 723b404..7984c3e 100644 --- a/Chapter9-1-4/config-repo/didispace-dev.properties +++ b/Chapter9-1-4/config-repo/didispace-dev.properties @@ -1 +1 @@ -from=local-dev \ No newline at end of file +from=git-dev \ No newline at end of file diff --git a/Chapter9-1-4/config-repo/didispace-prod.properties b/Chapter9-1-4/config-repo/didispace-prod.properties index 7be4356..5948e11 100644 --- a/Chapter9-1-4/config-repo/didispace-prod.properties +++ b/Chapter9-1-4/config-repo/didispace-prod.properties @@ -1 +1 @@ -from=local-prod \ No newline at end of file +from=git-prod \ No newline at end of file diff --git a/Chapter9-1-4/config-repo/didispace-test.properties b/Chapter9-1-4/config-repo/didispace-test.properties index fc22476..ea16457 100644 --- a/Chapter9-1-4/config-repo/didispace-test.properties +++ b/Chapter9-1-4/config-repo/didispace-test.properties @@ -1 +1 @@ -from=local-test \ No newline at end of file +from=git-test \ No newline at end of file diff --git a/Chapter9-1-4/config-server/src/main/resources/application.properties b/Chapter9-1-4/config-server/src/main/resources/application.properties index 99a8cb2..4157fdd 100644 --- a/Chapter9-1-4/config-server/src/main/resources/application.properties +++ b/Chapter9-1-4/config-server/src/main/resources/application.properties @@ -1,13 +1,14 @@ spring.application.name=config-server server.port=7001 +# git管理配置 spring.cloud.config.server.git.uri=http://git.oschina.net/didispace/SpringBoot-Learning/ -spring.cloud.config.server.git.searchPaths=Chapter9-1-4 +spring.cloud.config.server.git.searchPaths=Chapter9-1-4/config-repo spring.cloud.config.server.git.username=username spring.cloud.config.server.git.password=password # 开启本地配置 -#spring.profiles.active=native +spring.profiles.active=native diff --git a/Chapter9-1-4/config-server/src/main/resources/didispace-dev.properties b/Chapter9-1-4/config-server/src/main/resources/didispace-dev.properties new file mode 100644 index 0000000..723b404 --- /dev/null +++ b/Chapter9-1-4/config-server/src/main/resources/didispace-dev.properties @@ -0,0 +1 @@ +from=local-dev \ No newline at end of file diff --git a/Chapter9-1-4/config-server/src/main/resources/didispace-prod.properties b/Chapter9-1-4/config-server/src/main/resources/didispace-prod.properties new file mode 100644 index 0000000..7be4356 --- /dev/null +++ b/Chapter9-1-4/config-server/src/main/resources/didispace-prod.properties @@ -0,0 +1 @@ +from=local-prod \ No newline at end of file diff --git a/Chapter9-1-4/config-server/src/main/resources/didispace-test.properties b/Chapter9-1-4/config-server/src/main/resources/didispace-test.properties new file mode 100644 index 0000000..fc22476 --- /dev/null +++ b/Chapter9-1-4/config-server/src/main/resources/didispace-test.properties @@ -0,0 +1 @@ +from=local-test \ No newline at end of file