提交 437f9531 编写于 作者: Q qinyingjie

fix:config高可用

上级 ffd60f0b
......@@ -31,7 +31,7 @@
<module>springcloud-service-common</module>
<module>springcloud-service-portal</module>
<module>springcloud-service-config</module>
<module>springcloud-service-config-get</module>
<module>springcloud-service-config-client</module>
<module>springcloud-service-feign</module>
<module>springcloud-service-eureka</module>
</modules>
......
......@@ -7,9 +7,9 @@
<artifactId>springcloud-service-parent</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>springcloud-service-config-get</artifactId>
<artifactId>springcloud-service-config-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springcloud-service-config-get</name>
<name>springcloud-service-config-client</name>
<properties>
<java.version>1.8</java.version>
</properties>
......@@ -27,8 +27,19 @@
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
<artifactId>spring-cloud-config-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<build>
......
......@@ -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);
}
}
......@@ -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;
......
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: "*"
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
......@@ -23,6 +23,10 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
......
......@@ -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 {
......
......@@ -15,3 +15,9 @@ spring:
username: 13113691357
password: 15671628341qwe
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册