1.服务器端
2.客户端
1.服务器端
1.依赖+配置+启动注解
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-server</artifactId> </dependency>
server.port=12000
spring.application.name=demo-config
#eureka配置
eureka.client.serviceUrl.defaultZone=http://127.0.0.1:6868/eureka/
eureka.instance.prefer-ip-address=true
#config配置
spring.cloud.config.server.git.uri=https://gitee.com/ligenyun/demo-config.git
package com.ligy.school.config; 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; @SpringBootApplication @EnableEurekaClient @EnableConfigServer public class ConfigMain { public static void main(String[] args) { SpringApplication.run(ConfigMain.class); } }
ps:https://gitee.com/ligenyun/demo-config.git
这个地址,是码云的一个仓库地址;
配置后访问地址:localhost:12000/application-dev.properties