springcloud-config:详细配置

仓库配置

新建github仓库

新建

新建仓库

成功

成功

在本地硬盘上新建git仓库并克隆

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


  1. 尚硅谷周阳老师springcloud-config第一季+第二季还有自己的百度经验 ↩︎

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值