博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
第八篇: Spring Cloud Bus(Hoxton版本)
阅读量:4182 次
发布时间:2019-05-26

本文共 4140 字,大约阅读时间需要 13 分钟。

pom.xml

4.0.0
com.xiaobu
springcloud-demo
0.0.1-SNAPSHOT
com.xiaonbu
config-bus
0.0.1-SNAPSHOT
config-bus
config-bus project for Spring Boot
1.8
org.springframework.cloud
spring-cloud-starter-config
org.springframework.boot
spring-boot-starter
org.springframework.cloud
spring-cloud-starter-netflix-eureka-client
org.springframework.cloud
spring-cloud-starter-bus-amqp
org.springframework.boot
spring-boot-starter-actuator
org.springframework.cloud
spring-cloud-dependencies
${spring-cloud.version}
pom
import
org.springframework.boot
spring-boot-maven-plugin

bootstrap.properties

# 从config-server获取配置信息#server.port=7002#{application}#spring.application.name=xiaobu#{profile}#spring.cloud.config.profile=dev#{label}#spring.cloud.config.label=master# spring.cloud.config.uri=http://localhost:7001/# 从eureka-server获取配置信息#{application}spring.application.name=xiaobu#{profile}spring.cloud.config.profile=dev#{label}spring.cloud.config.label=masterspring.cloud.config.uri=http://localhost:7001/eureka.client.serviceUrl.defaultZone=http://localhost:8001/eureka/spring.cloud.config.discovery.enabled=truespring.cloud.config.discovery.serviceId=config-serverserver.port=7003

ConfigBusApplication

package com.xiaonbu;import lombok.extern.slf4j.Slf4j;import org.springframework.beans.factory.annotation.Value;import org.springframework.boot.CommandLineRunner;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.cloud.client.discovery.EnableDiscoveryClient;import org.springframework.cloud.context.config.annotation.RefreshScope;import org.springframework.cloud.netflix.eureka.EnableEurekaClient;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.RestController;@SpringBootApplication@EnableEurekaClient@EnableDiscoveryClient@RestController@RefreshScope@Slf4jpublic class ConfigBusApplication implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(ConfigBusApplication.class, args); } @Value("${server.port}") private String port; @Override public void run(String... args) throws Exception {
log.info("config-client 在端口{}启动成功", port); } @Value("${from}") String from; @GetMapping("/from") public String from() {
return from; }}

依次启动 eureka-server config-server config-bus

访问http://localhost:8001/

1610613732.png

访问 http://localhost:7003/from

git-dev-1.0 QAQ

修改代码仓库的文件内容 from=git-dev-1.0 hasagei!

先post一下 http://localhost:7003/actuator/bus-refresh

然后先前是G版本的 无论怎么post都不行,后面查资料才知道Greenwich.M1版本的bus总线/actuactor/bus-refresh时发生问题。

所以改成了H版本 一下就成功了。

org.springframework.boot
spring-boot-starter-parent
2.2.0.RELEASE
UTF-8
UTF-8
1.8
Hoxton.RELEASE

再访问 http://localhost:7003/from 出现

git-dev-1.0 hasagei!

转载地址:http://wkgai.baihongyu.com/

你可能感兴趣的文章
如何快速上手Linux操作系统?
查看>>
微信QQ等主流应用上线国产系统UOS:界面曝光
查看>>
3天,让你的C++从入门到精通
查看>>
这个「微信年度报告」你被骗了吗?
查看>>
可怕啊,阿里面试!
查看>>
疯传!某大厂P8面试题库遭到泄露!
查看>>
中国编程第一人,一人抵一城!
查看>>
【微信红包封面】最新!最全!
查看>>
最近线上发生的两个坑爹锅!
查看>>
腾讯QQ的回应来了~
查看>>
最新5款微信红包封面,来了 !!!
查看>>
哦嚯,被微服务给坑了...
查看>>
SCI审稿人亲授:机器学习在智能化时代下的应用
查看>>
安卓微信 8.0 内测版来啦!
查看>>
我劝你不要再留QQ邮箱了
查看>>
真香!用 4K 高清显示器写代码!(包邮送一台)
查看>>
神器!各行业必备!低调使用
查看>>
B 站,牛逼!
查看>>
微信状态视频、图片素材来啦!
查看>>
再见了!锤子!!!
查看>>