spring cloud 问题记录(六)配置中心报错Cannot pull from remote XX.git the working tree is not clean.

在使用配置中心拉取配置文件的时候,有时候总会遇到很多让人很郁闷的问题,如果本地缓存文件被更改的时候就会遇到以下问题:

 Cannot pull from remote https://git.zhubanxian.com/zhu/online_edu_config.git, the working tree is not clean.

而我遇到这个问题的原因就是因为吧本地的缓存给删了。

其实在Spring Cloud官网给出了答案
https://github.com/spring-cloud/spring-cloud-config/blob/master/docs/src/main/asciidoc/spring-cloud-config.adoc#force-pull-in-git-repositories

  Spring Cloud配置服务器会复制远程git存储库,如果本地副本变得不干净(例如,通过OS进程更改文件夹内容),那么Spring Cloud配置服务器就不能更新远程存储库中的本地副本。为了解决这个问题,有一个强制拉属性,如果本地副本是脏的,它将使Spring Cloud配置服务器从远程存储库中强制pull.
 

spring:
  application:
    name: public-config
  cloud:
    config:
      server:
        git:
          uri: https://git.zhubanxian.com/zhu/online_edu_config.git
          username: ***
          password: ***
          basedir: C:/work/config/tmp
          force-pull: true

添加 force-pull 属性 默认是false
同时在重新启动Config server的时候需要删除原来临时的配置文件

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值