【问题标题】:Spring Cloud Config - Cannot clone or checkout repository: ssh://git@github.com/<user>/repo.gitSpring Cloud Config - 无法克隆或签出存储库:ssh://git@github.com/<user>/repo.git
【发布时间】:2018-10-11 02:11:38
【问题描述】:

当我尝试使用 https 的 URL 时,它可以工作,但我不想拥有用户名和密码。我可以使用上面的 url 及其工作来执行 git clone。但是当我在代码中尝试并点击 localhost:8888/default 端点时,我得到了错误:

{
"error": "Not Found",
"message": "Cannot clone or checkout repository: ssh://git@github.com/<user>/config-repo.git",
"path": "/licensingservice/default",
"status": 404,
"timestamp": "2018-04-30T23:32:54.726+0000"
}

这是我的 application.yml 条目

server:
  port: 8888
spring:
  cloud:
    config:
      server:
        git:
          uri: ssh://git@github.com/<user>/config-repo.git
          searchPaths: licensingservice

我正在使用 Spring Cloud 配置 - Finchley.Not。不知道我错过了什么。请提出建议。

【问题讨论】:

  • 只要确保你使用'//',如下所示:spring.cloud.config.server.git.uri=E:\\config-repo

标签: spring-cloud-config


【解决方案1】:

需要检查的几件事:

  1. 您的 known_hosts 中有 github 吗?如果没有,即使您有可能导致错误的密钥对,它也会提示您输入密码。
  2. /home/{you}/.ssh/ 文件夹下是否有 SSH 密钥?
  3. 在生成密钥时,是否使用了密码?如果是这样,您需要在 YAML 文件中包含 passphrase 键。

如果以上都可以。然后下载spring-cloud-config-server,调试org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.class

祝你好运。

【讨论】:

    【解决方案2】:

    您必须将您机器的 ssh 密钥添加到 repo。

    应使用以下命令生成 Ssh 密钥: ssh-keygen -m PEM -t rsa -b 4096 -C "your_email@example.com"

    更多信息,您可以查看此链接

    https://skryvets.com/blog/2019/05/27/solved-issue-spring-cloud-config-server-private-ssh-key/

    【讨论】:

      【解决方案3】:

      我在 spring 云配置服务器上也遇到了类似的问题。您需要在 application.properties 文件中添加一个附加属性 spring.cloud.config.server.git.skip-ssl-validation=true

      【讨论】:

        猜你喜欢
        • 2018-06-14
        • 1970-01-01
        • 2017-02-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-10-19
        • 2017-08-07
        • 1970-01-01
        相关资源
        最近更新 更多