Man*_*uel 4 java bitbucket intellij-idea spring-boot spring-cloud-config
有点卡在上面了。虽然我看到有人就同一主题提出问题,并且已经尝试过,但仍然没有办法。
堆栈我使用-> mac(mojave),Intellij,jdk8,在mac本身上使用puttygen生成密钥,看起来像这样,这仅适用于我本地的springboot配置服务器。
我尝试了两种方法: spring.cloud.config.server.git.private-key=-----BEGIN RSA PRIVATE KEY-----\n MIIEowIBAAKCAQEAssBl7ZADFHBZrSnDPVhClH9HFzCaEPKEaO3MX7H5uBMTEL59\n CLRguWdCQJnvv2L6vSLyBb9ds05DHEzE2OqkU5VzYX4CC rU7t1ktZmy3cwyNc0g0\n ijJMInd47KG57Pi6nzpN/bVsLNiwRO3PZ7wUxgeQT6vh5euhBbTlvrFRbNMZm0Rf\n ... . .. ,,, F5vNwcngKk/tFFwX2XooikGliOCxHU66/KOckbNXqOaLBc+QlNsB\n -----结束 RSA 私钥 -----
给出错误:
应用程序无法启动
描述:
绑定到目标 org.springframework.boot.context.properties.bind.BindException:无法将“spring.cloud.config.server.git”下的属性绑定到 org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties 失败:
Reason: Property 'spring.cloud.config.server.git.privateKey' is not a valid private key
Run Code Online (Sandbox Code Playgroud)
2) spring.cloud.config.server.git.private-key=~/.ssh/temp/id_rsa spring.cloud.config.server.git.ignore-local-ssh-settings=true
并且仍然遇到与我上面分享的相同的错误。
3)在解决方案中存在一个SO问题,即密钥可能没有正确创建。现在我在正常开发中使用了相同的密钥,并且已经使用它一年了,并将酒吧添加到我的 bitbucket 存储库中,并且工作正常。它是我们自己的存储库(不是 git hub),我通常可以使用 ~/.ssh/id_rsa 中的密钥正常工作。因此,我从 ~/.ssh/id_rsa 文件创建 RSA 私钥到临时目录中,并将其用于配置服务器应用程序。
4)在已知的hosts文件中,大约有7个条目,其中1个是bitbucket服务器。及其 ssh-rsa。
想知道是否有分步指南或一些示例有人可以帮助我?
也许这会有所帮助,用户“introtj”在这里评论https://github.com/spring-cloud/spring-cloud-config/issues/1392,这对我有帮助。
JGit requires RSA keys in PEM format. Below is an example ssh-keygen (from openssh) command that will generate a key in the corect format:
ssh-keygen -m PEM -t rsa -b 4096
Run Code Online (Sandbox Code Playgroud)
2021 年 4 月 22 日更新
所以今天我决定从 yml 切换到properties,当然也遇到了与上面相同的错误。我知道密钥很好,因为它在 YAML 格式下运行良好。经过 2 个小时的反复试验,我终于成功了:
spring.cloud.config.server.git.private-key= \
-----BEGIN RSA PRIVATE KEY-----\n\
your_key_here_your_key_here_you\n\
your_key_here_your_key_here_you\n\
your_key_here_your_key_here_you\n\
your_key_here_your_key_here_you\n\
your_key_here_your_key_here_you\n\
-----END RSA PRIVATE KEY-----\n
Run Code Online (Sandbox Code Playgroud)
我使用的是 Spring Boot 2.4.5 和 Spring Cloud 2020.0.02
让我知道这个解决方案是否适合您。
| 归档时间: |
|
| 查看次数: |
11359 次 |
| 最近记录: |