关于spring cloud config 搭建总结(主要是http配置代理问题)

本文总结了Spring Cloud Config的搭建过程,重点讨论了如何解决内网客户端访问外网Git仓库的HTTP代理问题。在配置代理时,需在启动Config Server时设置系统属性,包括启用代理模式、指定代理IP和端口。同时,文中提到了客户端启动时可能出现的配置错误及日志分析的重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

首先,spring cloud config 的介绍网上一大堆,再此不做过多介绍,请参考下面几篇文章

http://www.ityouknow.com/springcloud/2017/05/26/springcloud-config-eureka-bus.html

https://www.jianshu.com/p/4a4355a6f38d

https://www.jianshu.com/p/ccffafb3be9f?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

搭建注意的几点:

1 config server pom文件的增加相应依赖

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-server</artifactId>
        </dependency>

2 client pom增加相应依赖

                <dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>

</dependency>

搭建过程遇到的问题:

1 config server 跟git的关系。由于client部署在内网,跟外网不通,然而git又部署在外网,所以中间需要加一个代理。

首先先搞清楚访问顺序:在启动config server 的时候,该项目并不会去clone git上的配置文件。只有当client要用到git上的文件时,config server才会去git上clone相应的配置文件。

加代理如下:



System.setProperty("http.proxySet", "true");  开始代理模式
System.setProperty("http.proxyHost", "代理ip");

System.setProperty("http.proxyPort", "代理端口");

2 在启动client时报错,一般问题都会出在配置文件中。

3 问题查找思路,多看日志

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值