Spring 云配置 - git-不允许上传包

Spring Cloud Config - git-upload-pack not permitted

我在 docker 环境中有一个 spring-boot 应用程序 运行ning,它连接到 Git 存储库以获取应用程序的配置。我的问题是应用程序在尝试获取 .properties 文件时有时会出错。这很奇怪,因为如果我更改用户和密码,同一个应用程序会恢复工作。

错误

2021-06-20 15:42:57.229  WARN 1 --- [nio-8888-exec-1] .c.s.e.MultipleJGitEnvironmentRepository : Error occured cloning to base directory.

org.eclipse.jgit.api.errors.TransportException: https://####@bitbucket.org/####/cup-configuration-files: git-upload-pack not permitted on 'https://####@bitbucket.org/####/cup-configuration-files/'
    at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:254) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
    at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:306) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
    at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:200) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]

我试过这个解决方案,但没有用:

application.yml

server:
    port: 8888
spring:
    application:
        name: config-server
    cloud:
        config:
            server:
                git:  
                    basedir: temp
                    password: ####
                    username: ####
                    uri: https://#######@bitbucket.org/########/cup-configuration-files
                    searchPaths: '{application}'
management:
        endpoints:
          web:
            exposure:
              include: "*"

我已经在 docker 容器中检查临时目录是否具有所有权限。

当我 运行 在本地环境中使用 mvn spring-boot:run 命令运行相同的应用程序时,它可以工作。

PS: Git 本地版本与 docker 环境不同。不知道是不是问题

我已经创建了一个 cup-configuration-files 目录,用 git 初始化它并进行了 git 拉取以获取所有文件,然后在 application.yml 我把 uri作为文件:

application.yml:

server:
    port: 8888
spring:
    application:
        name: config-server
    cloud:
        config:
            server:
                git:  
                    basedir: temp
                    password: ######
                    username: ######
                    uri: file:/cup-configuration-files
                    searchPaths: '{application}'
management:
        endpoints:
          web:
            exposure:
              include: "*"

当我通过向导在 Spring Tool Suit 4 (STS) 中克隆 Bitbucket 存储库时,我遇到了同样的错误,即“git-upload-pack not permitted”“Clone a Git 存储库”。我挣扎了好几个小时才意识到我们需要在 Bitbucket 中使用通过 add app password link 生成的密码。

这里有更多关于如何解决“git-upload-pack not permitted”错误的详细信息。

Bitbucket

  1. 转到 Bitbucket home

  2. 在左下角单击您的帐户图标。它将显示弹出菜单,其中之一是“个人设置”。单击相同。它会带你到你的 account settings.

  3. 在Bitbucket个人账户设置页面,您会看到菜单link“App passwords”,点击相同。在右侧面板上,将显示 App passwords page

  4. 在右侧页面,您会看到“创建应用密码”按钮。单击相同。它将向 add app password.

    显示详细信息

Git中心

如果您正在使用 GitHub,请注意 GitHub has deprecated passwords and you need to create a personal access token in GitHub as stated here. (Please refer this answer)