照例附上项目github链接。本项目实现的是将一个简单的天气预报系统一步一步改造成一个SpringCloud微服务系统的过程。本章主要讲解微服务的集中化配置。微服务为什么需要集中化配置微服务数量多,配置多手工管理配置繁琐使用Config实现Server端的配置中心集成Config Server添加依赖 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-server</artifactId> </dependency>@EnableConfigServer注解//@ServletComponentScan(basePackages=“com.demo.web.servlet”)@SpringBootApplication@EnableDiscoveryClient@EnableConfigServerpublic class Sifoudemo02Application { public static void main(String[] args) { SpringApplication.run(Sifoudemo02Application.class, args); }}修改配置文件spring.application.name: msa-weather-config-serverserver.port= 8088eureka.client.serviceUrl.defaultZone: http://localhost:8761/eureka/spring.cloud.config.server.git.uri=https://github.com/ShimmerPig/spring-cloud-config-server-test01spring.cloud.config.server.git.searchPaths=config-repo这里指定的是我github上面的一个仓库将服务端启动后,发送请求进行访问,可以查看在云端配置中心的配置文件,当以后需要使用繁多的配置时,我们可以通过此方法对服务进行集中化的配置。