天天看點

配置springcloud配置中心讀取github上的配置檔案報錯:com.jcraft.jsch.JSchException: Auth fail解決方案

首先,在配置中檢查要讀取的分支是否正确,從2020年幾月份開始,github上的master分支變為了mian分支。是以yml中讀取分支的配置應該是:label: main

其次,如果yml使用的是uri: [email protected]:springcloud-config.git這種ssh方式連接配接的話,需要進行其他的配置,是以我放棄了這種方式進行配置,而采用http/https方式進行配置。值得注意的是,采用http和https方式,如果沒配置免密的話,需要在配置檔案中加入密碼及使用者名。

詳細案例如下

server:
  port: 3344

spring:
  application:
    name:  cloud-config-center #注冊進Eureka伺服器的微服務名
  cloud:
    config:
      server:
        git:
        ####倉庫位址
          uri: https://github.com/wang692/springcloud-config.git #GitHub上面的git倉庫名字
        ####搜尋目錄,即倉庫名
          search-paths:
            - springcloud-config
      ####讀取分支,main即代表springcloud-config倉庫的master分支
      label: main