关于spring cloud config 搭建总结(主要是http配置代理问题)
首先,spring cloud config 的介绍网上一大堆,再此不做过多介绍,请参考下面几篇文章
http://www.ityouknow.com/springcloud/2017/05/26/springcloud-config-eureka-bus.html
https://www.jianshu.com/p/4a4355a6f38d
搭建注意的几点:
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 问题查找思路,多看日志