1. 程式人生 > >【Spring Cloud Finchley.SR + Spring Boot 2.0.6】 Bus

【Spring Cloud Finchley.SR + Spring Boot 2.0.6】 Bus

1、Config Server

1.1、maven配置

1.2、啟動類:

1.3、配置類

坑一:

必須去掉formLogin(),否則spring security無法認證,報401。

原始碼:

org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter.class:164

1.4、基本配置

1.5、config server配置(需要安裝Rabbit MQ

ERLang下載:http://www.erlang.org/downloads
RabbitMQ下載:http://www.rabbitmq.com/#support  (需要先安裝erlang(語言))
管理介面安裝:http://www.rabbitmq.com/management.html
rabbitmq-plugins enable rabbitmq_management


管理介面地址:http://localhost:15672/
帳號密碼:guest guest

坑二:

必須手動開啟refresh、bus-refresh端點,通過management.dendpints.web.exposure.incluede(此處是開啟所有)

1.6、banner配置(自己喜歡就好)

1.7、logback-spring配置(自己喜歡就好)

2、Config Client

2.1、maven配置

2.2、啟動類配置

2.3、Controller配置(加上註解@RefreshScope

2.4、config client配置

坑三:

使用service-id來配置config client時,將base config放入application.yml中無法獲取配置,需要放入bootstrap.yml中。

使用uri配置是OK的。。。

使用uri來配置:

2.5、Mybatis配置

3、Git

https://gitee.com/mycode2018/darren-micro-config(暫時未開放)

Mybatis配置:

基本配置(本來這些配置是放在application.yml中的,後面使用service-id無法獲取,詳情見坑三

):

4、測試

4.1、訪問http://localhost:7771/test檢視test的值

4.2、修改Git配置檔案

4.3、通過postmen重新整理配置(坑一:返回碼是401

http://localhost:8764/actuator/bus-refresh:此連結是重新整理所有client配置

4.4、檢視重新整理結果

5、配置webhooks

作用:git提交時,請求http://localhost:8764/actuator/bus-refresh重新整理配置(地址必須是域名哦。。。)