记 Springcloud config 通过 GitHub 获取配置信息 报错集锦

cannot open git-upload-pack 或者页面报 404 (org.springframework.cloud.config.server.environment.NoSuchRepositoryException: Cannot clone or checkout repository:XXXX) 时可能是连接 GitHub 的问题:

1、科学上网。IDEA可以通过 settings 设置代理

2、查看 yml 配置

1)如果是公共仓库无需设置 username 和 password,反之需要设置。

2)这里采用的是 http 连接,ssh 连接需要密钥还没学会

3)需要跳过 ssl 校验

4)再检查一下分支名称对不对,有些是 main 给写成 master 了

5)如果报环境的错,还可能是 jar 包冲突。见 https://blog.csdn.net/main_Scanner01/article/details/121653238

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Spring Boot Cloud 远程配置可以使用 GitHub 存储配置文件,以便在不同的环境中使用相同的配置。以下是如何在 Spring Boot Cloud 中使用 GitHub 存储配置文件的步骤: 1. 在 GitHub 上创建一个仓库,并在仓库中创建一个名为 `application.yml` 的配置文件,内容如下: ``` server: port: 8080 spring: datasource: url: jdbc:mysql://localhost:3306/mydb username: myuser password: mypassword ``` 2. 在 Spring Boot 项目的 `src/main/resources` 目录中创建一个名为 `bootstrap.yml` 的配置文件,内容如下: ``` spring: cloud: config: uri: https://github.com/your-github-username/your-github-repo/ username: your-github-username password: your-github-password profile: dev ``` 其中,`uri` 指定了 GitHub 仓库的 URL,`username` 和 `password` 是 GitHub 的用户名和密码,`profile` 指定了要使用的配置文件的环境。 3. 在 Spring Boot 项目中添加以下 Maven 依赖: ``` <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> </dependency> ``` 4. 在 Spring Boot 项目的启动类上添加 `@EnableConfigServer` 注解: ``` @EnableConfigServer @SpringBootApplication public class ConfigServerApplication { public static void main(String[] args) { SpringApplication.run(ConfigServerApplication.class, args); } } ``` 5. 启动 Spring Boot 项目,访问 `http://localhost:8080/application/dev` 可以看到 GitHub 上的配置文件已被加载。 以上就是使用 GitHub 存储配置文件的 Spring Boot Cloud 远程配置的步骤。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值