Detailed reference: "Sprin Cloud and Docker Micro-service Architecture combat" p162-9.9.4 Festival
The changes to be made are:
1. Add SPRING-CLOUD-STARTER-BUS-AMQP package to Spring Cloud Config Server service side
<?xml version= "1.0" encoding= "UTF-8"? ><project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "http ://www.w3.org/2001/XMLSchema-instance "xsi:schemalocation=" http://maven.apache.org/POM/4.0.0/http Maven.apache.org/xsd/maven-4.0.0.xsd "><modelVersion>4.0.0</modelVersion><groupId> Com.thunisoft</groupid><artifactid>thunisoft-microservice-config</artifactid><version> 0.0.1-snapshot</version><packaging>jar</packaging><name>thunisoft-microservice-config </name><description>demo Project for Spring boot</description><parent><groupid> org.springframework.boot</groupid><artifactid>spring-boot-starter-parent</artifactid>< Version>1.5.10.release</version><relativepath/> <!--lookup parent from repository--></ parent><properties><project.build.sourceencoding>utf-8</project.build.sourceencoding>< Project.reporting.outputEncoding>utf-8</project.reporting.outputencoding><java.version>1.8</java.version>< spring-cloud.version>edgware.sr2</spring-cloud.version></properties><dependencies>< Dependency><groupid>org.springframework.cloud</groupid><artifactid> Spring-cloud-config-server</artifactid></dependency><dependency><groupid> Org.springframework.cloud</groupid><artifactid>spring-cloud-starter-bus-amqp</artifactid> </dependency><dependency><groupId>org.springframework.boot</groupId><artifactId> Spring-boot-starter-test</artifactid><scope>test</scope></dependency></dependencies ><dependencymanagement><dependencies><dependency><groupid>org.springframework.cloud </groupid><artifactid>spring-cloud-dependencies</artifactid><version>${ spring-cloud.version}</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencymanagement><build>< Plugins><plugin><groupid>org.springframework.boot</groupid><artifactid> Spring-boot-maven-plugin</artifactid></plugin></plugins></build></project>
2. Add Configuration
RABBITMQ: host:localhost port:5672 username:guest password:guest
Spring: application: name:thunisoft-microservice-configs Cloud: config: server: git: uri:https://gitee.com/ultrastrong/spring-cloud-config clone-on-start:true # boot time on clone config repository Default-application-name:thunisoft-microservice-foo rabbitmq: host:localhost port:5672 Username:guest password:guestserver: port:8979# default off permission validation management: Security: Enabled:false
Do not forget to turn off server-side security authentication, otherwise you will not be able to access the endpoint.
3, when using the/bus/refresh endpoint refresh configuration, as long as the server side on the line, so that all the endpoints will be able to receive the update request.
Http://localhost:8979/bus/refresh
Spring Cloud Config automatically refreshes all node schema retrofits