Spring cloud config server Could not fetch remote for master remote: 解決

公司最近遷移了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.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章