【问题标题】:Spring Cloud Config - git-upload-pack not permittedSpring Cloud Config - 不允许使用 git-upload-pack
【发布时间】:2021-09-04 13:57:09
【问题描述】:

我有一个在 docker 环境上运行的 spring-boot 应用程序,它连接到 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]

我已经尝试过这个解决方案,但它不起作用:create basedir directory

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 环境不同。不知道会不会有问题。

【问题讨论】:

  • 找到解决方案了吗?
  • 我创建了一个本地目录并将所有内容从 bitbucket 复制到该目录并在 application.yml 上进行设置
  • 谢谢。刚才我修好了。使用我的同事 bitbucket 帐户。它不适用于我的帐户。
  • 一两天你就需要换了,我也做了这个攻略。
  • 好的,谢谢。如果发生这种情况,我会更改并在 cmets 中通知您

标签: git spring-boot spring-cloud-config-server


【解决方案1】:

我创建了一个 cup-configuration-files 目录,用 git 对其进行了初始化,并进行了 git pull 以获取所有文件,并在 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: "*"

【讨论】:

    【解决方案2】:

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

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

    比特桶

    1. 转到 Bitbucket home

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

    3. 在Bitbucket个人账户设置页面,你会看到菜单链接“应用密码”,点击相同。在右侧面板上,将显示App passwords page

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

    GitHub

    如果您使用的是 GitHub,请告知GitHub has deprecated passwords,并且您需要create a personal access token in GitHub,如here 所述。 (请参考this answer)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-05
      • 2012-05-15
      • 2017-07-13
      • 2019-10-07
      • 2012-07-30
      • 1970-01-01
      • 2012-06-23
      • 2012-05-07
      相关资源
      最近更新 更多