springcloud-config
仓库配置
新建github仓库
新建
成功
在本地硬盘上新建git仓库并克隆
git命令
当前目录下没有git库
克隆github上仓库到本地
本地生成一个空目录
该目录隐藏目录有.git文件
.git文件夹下有git仓库,本地库,远程库,临时库等等
进入该文件夹,已经检测到是一个仓库,并且在master分支下,该仓库下什么都没有
将本地仓库的文件推送到github仓库中
在本地仓库新建.yml配置文件文件
此时,git已经监控到了我本地仓库已经新添加了文件(文件名为红色)
上传文件命令
上传成功之后,github仓库会出现刚刚上传的文件
springcloud-config分布式配置中心
新建module
pom文件依赖
<dependencies>
<!-- config-server 相关依赖-->
<dependency>
<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>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- 热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
配置yml
server:
port: 3344
spring:
application:
name: cloud-config-center #注册进Eureka服务器的微服务名
cloud:
config:
server:
git:
uri: https://github.com/lqklqk/springcloud-config.git #连接到GitHub上面的仓库
###搜索目录
search-paths:
- springcloud-config
label: master
#服务注册到eureka地址
eureka:
client:
service-url:
defaultZone: http://localhost:7001/eureka
主启动类
@SpringBootApplication
@EnableConfigServer
public class ConfigCenterMain3344 {
public static void main(String[] args) {
SpringApplication.run(ConfigCenterMain3344.class,args);
}
}
访问规则
eg:http://config-3344.com:3344/master/config-test.yml
参考。1
尚硅谷周阳老师springcloud-config第一季+第二季还有自己的百度经验 ↩︎