首页 > 解决方案 > 使用私有 git 存储库配置服务器

问题描述

我想在我的配置服务器上使用私有 git 存储库。这是我的application.yml

server:
  port: 100
spring:
  application:
    name: smth-config-server
  cloud:
    config:
      server:
        git:
          uri: https://github.com/smth/smth
          default-label: main
          username: smth
          password: smth
          host-key-algorithm: ssh-rsa
          ignore-local-ssh-settings: true
          host-key: ssh-rsa smth== github.com
          private-key: -----BEGIN RSA PRIVATE KEY-----
            smth
            -----END RSA PRIVATE KEY-----

我收到以下错误:

Caused by: org.eclipse.jgit.errors.TransportException: https://github.com/smth/smth: not authorized
    at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:544)

我应该如何解决它?

标签: springgitspring-bootspring-cloudspring-cloud-config-server

解决方案


要使用私有存储库,您必须在密码属性上使用 git 访问令牌(您可以按照此步骤生成)。

所以例如

server:
  port: 8888

spring:
  cloud:
    config:
      server:
        git:
          uri: yourgithubrepo 
          username: ${GIT_USER}
          password: pasteyouraccesstoken
          default-label: "main"  

那应该工作


推荐阅读