diff --git a/pom.xml b/pom.xml index 048a005ac7e902c0ca3e8d8289b194d89a544acd..a5c2f5e33f6375b8cc5832f459145c78f79effcd 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ springcloud-service-common springcloud-service-portal springcloud-service-config - springcloud-service-config-get + springcloud-service-config-client springcloud-service-feign springcloud-service-eureka diff --git a/springcloud-service-config-get/pom.xml b/springcloud-service-config-client/pom.xml similarity index 71% rename from springcloud-service-config-get/pom.xml rename to springcloud-service-config-client/pom.xml index cce748cd2a54c32266a6fb22b89fc1c09bd94b92..50c837ec29c44ef27d25497bb178166b3c8bd7bf 100644 --- a/springcloud-service-config-get/pom.xml +++ b/springcloud-service-config-client/pom.xml @@ -7,9 +7,9 @@ springcloud-service-parent 1.0.0 - springcloud-service-config-get + springcloud-service-config-client 0.0.1-SNAPSHOT - springcloud-service-config-get + springcloud-service-config-client 1.8 @@ -27,8 +27,19 @@ org.springframework.cloud - spring-cloud-starter-config + spring-cloud-config-client + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + + + + org.springframework.boot + spring-boot-starter-actuator + + + diff --git a/springcloud-service-config-get/src/main/java/com/kwan/springcloud/ConfigGetApplication.java b/springcloud-service-config-client/src/main/java/com/kwan/springcloud/ConfigClientApplication.java similarity index 54% rename from springcloud-service-config-get/src/main/java/com/kwan/springcloud/ConfigGetApplication.java rename to springcloud-service-config-client/src/main/java/com/kwan/springcloud/ConfigClientApplication.java index 79ca599d7a09b0eb0066a9effca7fabb3ac87eeb..518e3602b44d611cbf37aa1d22a46410c0d9d93b 100644 --- a/springcloud-service-config-get/src/main/java/com/kwan/springcloud/ConfigGetApplication.java +++ b/springcloud-service-config-client/src/main/java/com/kwan/springcloud/ConfigClientApplication.java @@ -2,14 +2,15 @@ package com.kwan.springcloud; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.eureka.EnableEurekaClient; - +@EnableEurekaClient @SpringBootApplication -public class ConfigGetApplication { +public class ConfigClientApplication { public static void main(String[] args) { - SpringApplication.run(ConfigGetApplication.class, args); + SpringApplication.run(ConfigClientApplication.class, args); } } diff --git a/springcloud-service-config-get/src/main/java/com/kwan/springcloud/controller/ConfigGetController.java b/springcloud-service-config-client/src/main/java/com/kwan/springcloud/controller/ConfigClientController.java similarity index 66% rename from springcloud-service-config-get/src/main/java/com/kwan/springcloud/controller/ConfigGetController.java rename to springcloud-service-config-client/src/main/java/com/kwan/springcloud/controller/ConfigClientController.java index b2a16349d8334ddfb3931bc6d5bd5f0b320a42d5..5e5c5808d907889f7ac6383cd17bd0f3bb35f4b6 100644 --- a/springcloud-service-config-get/src/main/java/com/kwan/springcloud/controller/ConfigGetController.java +++ b/springcloud-service-config-client/src/main/java/com/kwan/springcloud/controller/ConfigClientController.java @@ -5,9 +5,17 @@ import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +/** + * 需要向客户端发送post请求动态刷新才能生效 + * curl -X POST "http://localhost:7002/actuator/refresh" + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/1/10 17:26 + */ @RefreshScope @RestController -class ConfigGetController { +class ConfigClientController { @Value("${from}") private String from; diff --git a/springcloud-service-config-client/src/main/resources/bootstrap.yml b/springcloud-service-config-client/src/main/resources/bootstrap.yml new file mode 100644 index 0000000000000000000000000000000000000000..51a44db11e6986a9084d3478a21e54c4cb83f74a --- /dev/null +++ b/springcloud-service-config-client/src/main/resources/bootstrap.yml @@ -0,0 +1,24 @@ +server: + port: 7002 +spring: + application: + name: didispace + cloud: + config: + label: master #分支名称 + profile: dev #读取后缀名称 + uri: http://localhost:7001/ #配置中心地址k + #上述3个综合:master分支上config-dev.yml的配置文件被读取 + #http://localhost:7001/master/didispace-dev.yml +eureka: + client: + fetch-registry: true + register-with-eureka: true + service-url: + defaultZone: http://eureka8767:8767/eureka/,http://eureka8768:8768/eureka/,http://eureka8769:8769/eureka/ +management: + endpoints: + web: + exposure: + include: "*" + diff --git a/springcloud-service-config-get/src/test/java/com/kwan/springcloud/PortalApplicationTests.java b/springcloud-service-config-client/src/test/java/com/kwan/springcloud/PortalApplicationTests.java similarity index 100% rename from springcloud-service-config-get/src/test/java/com/kwan/springcloud/PortalApplicationTests.java rename to springcloud-service-config-client/src/test/java/com/kwan/springcloud/PortalApplicationTests.java diff --git a/springcloud-service-config-get/src/main/resources/bootstrap.properties b/springcloud-service-config-get/src/main/resources/bootstrap.properties deleted file mode 100644 index 15cca3d1cfd651273764e20d680a614ce429cb06..0000000000000000000000000000000000000000 --- a/springcloud-service-config-get/src/main/resources/bootstrap.properties +++ /dev/null @@ -1,5 +0,0 @@ -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/pom.xml b/springcloud-service-config/pom.xml index 3f55457b01805ec1b7060a5da73bce7ff170d755..ac531cda57507dfd6767a7f27904b5787e84ee56 100644 --- a/springcloud-service-config/pom.xml +++ b/springcloud-service-config/pom.xml @@ -23,6 +23,10 @@ org.springframework.cloud spring-cloud-config-server + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + 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 f86619ac49b6c0c6aca99c903f5d7df53cc1a119..b5fad817215eed001dc1818c4c0a3109cebb830e 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 @@ -3,7 +3,9 @@ package com.kwan.springcloud; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.config.server.EnableConfigServer; +import org.springframework.cloud.netflix.eureka.EnableEurekaClient; +@EnableEurekaClient @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 bea35a7eb7c2126ace5663a62a86f675067f2b50..ea21a13aeb5d0d8e306fb6e07f03ec8ce94dc819 100644 --- a/springcloud-service-config/src/main/resources/application.yaml +++ b/springcloud-service-config/src/main/resources/application.yaml @@ -14,4 +14,10 @@ spring: - config-repo username: 13113691357 password: 15671628341qwe - label: master \ No newline at end of file + label: master + +#服务提供者 +eureka: + client: + service-url: + defaultZone: http://eureka8767:8767/eureka/,http://eureka8768:8768/eureka/,http://eureka8769:8769/eureka/ \ 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 deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000