From ffd60f0b947ecb85c029c8314540acf7f0abb26d Mon Sep 17 00:00:00 2001 From: qinyingjie Date: Tue, 10 Jan 2023 17:17:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:config-get=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 1 + springcloud-service-config-get/pom.xml | 42 +++++++++++++++++++ .../springcloud/ConfigGetApplication.java | 15 +++++++ .../controller/ConfigGetController.java | 21 ++++++++++ .../src/main/resources/bootstrap.properties | 5 +++ .../springcloud/PortalApplicationTests.java | 13 ++++++ springcloud-service-config/pom.xml | 27 +++++------- .../kwan/springcloud/ConfigApplication.java | 2 - .../src/main/resources/application.yaml | 12 ++---- .../src/main/resources/bootstrap.properties | 0 springcloud-service-portal/pom.xml | 1 + 11 files changed, 113 insertions(+), 26 deletions(-) create mode 100644 springcloud-service-config-get/pom.xml create mode 100644 springcloud-service-config-get/src/main/java/com/kwan/springcloud/ConfigGetApplication.java create mode 100644 springcloud-service-config-get/src/main/java/com/kwan/springcloud/controller/ConfigGetController.java create mode 100644 springcloud-service-config-get/src/main/resources/bootstrap.properties create mode 100644 springcloud-service-config-get/src/test/java/com/kwan/springcloud/PortalApplicationTests.java create mode 100644 springcloud-service-config/src/main/resources/bootstrap.properties diff --git a/pom.xml b/pom.xml index c49c15d..048a005 100644 --- a/pom.xml +++ b/pom.xml @@ -31,6 +31,7 @@ springcloud-service-common springcloud-service-portal springcloud-service-config + springcloud-service-config-get springcloud-service-feign springcloud-service-eureka diff --git a/springcloud-service-config-get/pom.xml b/springcloud-service-config-get/pom.xml new file mode 100644 index 0000000..cce748c --- /dev/null +++ b/springcloud-service-config-get/pom.xml @@ -0,0 +1,42 @@ + + + 4.0.0 + + com.kwan.springcloud + springcloud-service-parent + 1.0.0 + + springcloud-service-config-get + 0.0.1-SNAPSHOT + springcloud-service-config-get + + 1.8 + + + + com.kwan.springcloud + springcloud-service-common + 1.0.0 + compile + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.cloud + spring-cloud-starter-config + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/springcloud-service-config-get/src/main/java/com/kwan/springcloud/ConfigGetApplication.java b/springcloud-service-config-get/src/main/java/com/kwan/springcloud/ConfigGetApplication.java new file mode 100644 index 0000000..79ca599 --- /dev/null +++ b/springcloud-service-config-get/src/main/java/com/kwan/springcloud/ConfigGetApplication.java @@ -0,0 +1,15 @@ +package com.kwan.springcloud; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +@SpringBootApplication +public class ConfigGetApplication { + + public static void main(String[] args) { + + SpringApplication.run(ConfigGetApplication.class, args); + } + +} diff --git a/springcloud-service-config-get/src/main/java/com/kwan/springcloud/controller/ConfigGetController.java b/springcloud-service-config-get/src/main/java/com/kwan/springcloud/controller/ConfigGetController.java new file mode 100644 index 0000000..b2a1634 --- /dev/null +++ b/springcloud-service-config-get/src/main/java/com/kwan/springcloud/controller/ConfigGetController.java @@ -0,0 +1,21 @@ +package com.kwan.springcloud.controller; + +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 ConfigGetController { + + @Value("${from}") + private String from; + + @RequestMapping("/from") + public String from() { + + return this.from; + } + +} \ No newline at end of file diff --git a/springcloud-service-config-get/src/main/resources/bootstrap.properties b/springcloud-service-config-get/src/main/resources/bootstrap.properties new file mode 100644 index 0000000..15cca3d --- /dev/null +++ b/springcloud-service-config-get/src/main/resources/bootstrap.properties @@ -0,0 +1,5 @@ +spring.application.name=didispace +spring.cloud.config.profile=dev +spring.cloud.config.label=master +spring.cloud.config.uri=http://localhost:7001/ +server.port=7002 \ No newline at end of file diff --git a/springcloud-service-config-get/src/test/java/com/kwan/springcloud/PortalApplicationTests.java b/springcloud-service-config-get/src/test/java/com/kwan/springcloud/PortalApplicationTests.java new file mode 100644 index 0000000..1a8e650 --- /dev/null +++ b/springcloud-service-config-get/src/test/java/com/kwan/springcloud/PortalApplicationTests.java @@ -0,0 +1,13 @@ +package com.kwan.springcloud; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class PortalApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/springcloud-service-config/pom.xml b/springcloud-service-config/pom.xml index b07b50d..3f55457 100644 --- a/springcloud-service-config/pom.xml +++ b/springcloud-service-config/pom.xml @@ -14,33 +14,28 @@ 1.8 - - - com.kwan.springcloud - springcloud-service-common - 1.0.0 - compile - org.springframework.boot spring-boot-starter-test test - - - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-server - - - org.springframework.cloud spring-cloud-config-server - 1.4.7.RELEASE + + + + org.springframework.cloud + spring-cloud-dependencies + Hoxton.SR12 + pom + import + + + diff --git a/springcloud-service-config/src/main/java/com/kwan/springcloud/ConfigApplication.java b/springcloud-service-config/src/main/java/com/kwan/springcloud/ConfigApplication.java index f6341b9..f86619a 100644 --- a/springcloud-service-config/src/main/java/com/kwan/springcloud/ConfigApplication.java +++ b/springcloud-service-config/src/main/java/com/kwan/springcloud/ConfigApplication.java @@ -2,10 +2,8 @@ package com.kwan.springcloud; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.config.server.EnableConfigServer; -@EnableDiscoveryClient @EnableConfigServer @SpringBootApplication public class ConfigApplication { diff --git a/springcloud-service-config/src/main/resources/application.yaml b/springcloud-service-config/src/main/resources/application.yaml index c1066c8..bea35a7 100644 --- a/springcloud-service-config/src/main/resources/application.yaml +++ b/springcloud-service-config/src/main/resources/application.yaml @@ -9,13 +9,9 @@ spring: config: server: git: - uri: http://gitcode.net/qyj19920704/springcloud-config - searchPaths: config-repo + uri: https://gitcode.net/qyj19920704/springcloud-config.git + search-paths: + - config-repo username: 13113691357 password: 15671628341qwe - -#服务提供者 -eureka: - client: - service-url: - defaultZone: http://eureka8767:8767/eureka/,http://eureka8768:8768/eureka/,http://eureka8769:8769/eureka/ \ No newline at end of file + label: master \ No newline at end of file diff --git a/springcloud-service-config/src/main/resources/bootstrap.properties b/springcloud-service-config/src/main/resources/bootstrap.properties new file mode 100644 index 0000000..e69de29 diff --git a/springcloud-service-portal/pom.xml b/springcloud-service-portal/pom.xml index 915faf4..516cea0 100644 --- a/springcloud-service-portal/pom.xml +++ b/springcloud-service-portal/pom.xml @@ -30,6 +30,7 @@ spring-cloud-starter-netflix-eureka-server + -- GitLab