Spring 云配置 - Git 存储库错误

Spring Cloud Config - Git Repository Errors

Spring 云配置框架:

我正在尝试将 spring 云配置集成到 java 项目中,后端存储库 git 是 bitbucket。基本上,我在不同的场合更频繁地遇到两个错误。

2020-04-11 17:08:59.265  WARN 2792 --- [           main] .c.s.e.MultipleJGitEnvironmentRepository : Could not fetch remote for master remote: https://user@bitbucket.org/workspace/config-repo.git

在上述情况下,它使用缓存版本并且tomcat/undertow服务器启动没有任何问题。

2020-04-11 17:09:03.774  INFO 2792 --- [           main] o.s.c.c.s.e.NativeEnvironmentRepository  : Adding property source: file:/var/folders/6m/1cgw7zvn3rsb8j5kskflhvrr0000gn/T/config-repo-2822438633438126334/api-gateway.yml
2020-04-11 17:09:03.774  INFO 2792 --- [           main] o.s.c.c.s.e.NativeEnvironmentRepository  : Adding property source: file:/var/folders/6m/1cgw7zvn3rsb8j5kskflhvrr0000gn/T/config-repo-2822438633438126334/discovery-service.yml
2020-04-11 17:09:03.775  INFO 2792 --- [           main] o.s.c.c.s.e.NativeEnvironmentRepository  : Adding property source: file:/var/folders/6m/1cgw7zvn3rsb8j5kskflhvrr0000gn/T/config-repo-2822438633438126334/config-service.yml

Git 版本:

git version 2.24.0

错误 1:git-上传包

2020-04-11 00:00:20 - 警告克隆到基本目录时出错。

org.eclipse.jgit.api.errors.TransportException: https://<username>@bitbucket.org/<workspace>/config-repo.git: git-upload-pack not permitted on 'https://beatles89@bitbucket.org/workspace/config-repo.git/'

正在启动 spring 云配置服务器,我随机收到此错误。深入研究这个问题后,我发现 bitbucket 不支持 git-upload-pack。但是2年前被举报,建议还原GIT版本

错误 2:不支持身份验证

org.eclipse.jgit.api.errors.TransportException: https://bitbucket.org/user/repo.git: authentication not supported

我在执行器上点击 /refresh 以从远程配置存储库获取刷新的属性时出现上述错误。有时它可以正常工作,有时会抛出以上错误。

curl localhost:8060/refresh -d {} -H "Content-Type: application/json"

执行器刷新命令错误:

{"timestamp":"2020-04-10T16:35:41.144+0000","status":500,"error":"Internal Server Error","message":"Request processing failed; nested exception is org.springframework.cloud.config.server.environment.NoSuchRepositoryException: Cannot clone or checkout repository: https://beatles89@bitbucket.org/augmentedcloud/ac-config-repo.git","path":"/refresh"}

注意:作为旁注,我已经单独克隆了指定的存储库进行测试,并且它没有任何身份验证问题。

Spring 云配置框架

Spring Cloud Config 框架基本上提供 git 作为 remote/cache fetch/load .properties 的后端存储库。您必须为基本目录定义提供 write 权限 git 到 clone/checkout 来自远程的 .properties

spring:
  cloud:
    config:
      server:
        git:
          basedir: ${AC_CONFIG_SERVICE_GIT_BASE_DIR}
          uri: ${AC_CONFIG_SERVICE_GIT_REMOTE_URI}
          username: ${AC_CONFIG_SERVICE_GIT_REMOTE_USER}
          password: ${AC_CONFIG_SERVICE_GIT_REMOTE_PASSWORD}
          passphrase: ${AC_CONFIG_SERVICE_GIT_REMOTE_PASSPHRASE}
          skip-ssl-validation: true
          timeout: 10

Note: Otherwise, on every server startup it will either complain for .properties with different errors or load the cached version of .properties from local repository. By default, basedir read from this location /var/tmp and spring cloud config framework is looking for the write permissions on parent directory which in this case /var - Hint: Safety Precautions Triggered.

为了安全起见并且不想破坏您的 OSX,为 basedir 定义了您自己的自定义位置之一,例如 /Users/<....>/Documents/tmp。因为每次,git 都会在远程存储库中查找 新更改 ,如果找到,它将拉下新的 .properties,这需要删除以前的文件。

从那以后,我在日志中定义了 basedir 没有遇到来自 spring 云配置框架 的任何错误。