我有一个在 docker 环境中运行的 spring-boot 应用程序,它连接到 Git 存储库以获取应用程序的配置。我的问题是,当尝试获取 .properties 文件时,应用程序有时会出错。这很奇怪,因为如果我更改用户和密码,同一个应用程序就会恢复工作。
Error
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]
我已经尝试过这个解决方案,但它不起作用:创建basedir目录 https://stackoverflow.com/a/61344510/8405699.
应用程序.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 pull 来获取所有文件,并在 application.yml 上将 uri 作为文件:
应用程序.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: "*"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)