公司最近迁移了git仓库  修改了  spring cloud repo git的地址 

但是Sping Cloud Config server  服务器的git repo地址还是没有改变还是以前的git地址,错误如下

 c.s.e.MultipleJGitEnvironmentRepository : Cannot pull from remote 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:
  cloud:
    config:
      server:
        git:
          uri: https://github.com/spring-cloud-samples/config-repo
          force-pull: true
添加 force-pull 属性 默认是true

同时在重新启动Config server的时候需要删除临时 git config-repo- 文件 以下为官网提示


With VCS based backends (git, svn) files are checked out or cloned to the local filesystem. By default they are put in the system temporary directory with a prefix of config-repo-. On linux, for example it could be /tmp/config-repo-<randomid>. Some operating systems routinely clean out temporary directories. This can lead to unexpected behaviour such as missing properties. To avoid this problem, change the directory Config Server uses, by setting spring.cloud.config.server.git.basedir or spring.cloud.config.server.svn.basedir to a directory that does not reside in the system temp structure.

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐