Springcloud 集成 Turbine

1.搭建Springcloud项目

项目结构如下:

我们将在base、demo和turbine模块搭建

base(9005)、demo(9002)为正常项目

turbine(8031)为监控模块

2.项目配置

该项目使用nacos作为注册和配置中心,具体使用方法不做累述

1.base模块配置(demo模块相同):

  • maven依赖

    <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-hystrix</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId></dependency>
    
  • 修改配置文件

    management:endpoints:web:exposure:include: "*"cors:allowed-origins: "*"allowed-methods: "*"
    
  • 修改配置文件

    @EnableDiscoveryClient
    @EnableHystrix
    @EnableHystrixDashboard
    @EnableCircuitBreaker
    @RestController
    @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
    @MapperScan({"com.manage.cloud.mapper"})
    public class BaseApplication {@Value("${server.port}")private String port;public static void main(String[] args) {SpringApplication.run(BaseApplication.class, args);}@RequestMapping("/hi")@HystrixCommand(fallbackMethod = "hiError")public String home(@RequestParam(value = "name", defaultValue = "evan") String name) {return "hi " + name + " ,i am from port:" + port;}public String hiError(String name) {return "hi,"+name+",sorry,error!";}}
    

2. Turbine配置

  • maven依赖,Turbine要排除Eureka依赖,否则启动报错

            <!--集群监控--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-turbine</artifactId><version>1.4.7.RELEASE</version><exclusions><exclusion><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-netflix-eureka-client</artifactId></exclusion><exclusion><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-client</artifactId></exclusion></exclusions></dependency><!--注册中心--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId><version>${nacos.version}</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId><exclusions><exclusion><groupId>org.hdrhistogram</groupId><artifactId>HdrHistogram</artifactId></exclusion></exclusions></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-hystrix</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId></dependency>
  • 配置文件

    management:endpoints:web:exposure:include: "*"cors:allowed-origins: "*"allowed-methods: "*"hystrix:dashboard:proxy-stream-allow-list: "*"
    turbine:app-config: base,demoaggregator:clusterConfig: defaultclusterNameExpression: new String("default")combine-host: trueinstanceUrlSuffix:default: actuator/hystrix.stream
    
  • 启动类

    @SpringBootApplication
    @EnableDiscoveryClient
    @RestController
    @EnableHystrix
    @EnableHystrixDashboard
    @EnableCircuitBreaker
    @EnableTurbine
    public class TurbineApplication {public static void main(String[] args) {SpringApplication.run(TurbineApplication.class, args);}
    }
    

3.测试

1.分别启动demo/base/turbin项目

启动后可以在Nacos查看是否启动成功

2.访问dashboard页面

http://localhost:8031/hystrix

3.查看集群监控

4.调用服务

分别调用http://localhost:9005/hi和http://localhost:9005/hi

Springcloud 集成 Turbine相关推荐

  1. SpringCloud集成Security安全(Config配置中心)

    1.说明 为了保护配置中心的敏感数据, 需要对Config Server进行安全保护, 本文基于Spring Security方案, 为Config Server增加最简单的Basic安全认证. 2. ...

  2. SpringBoot与SpringCloud集成

    SpringBoot与SpringCloud集成 : 简介 Spring Cloud是一系列框架的有序集合.它利用Spring Boot的开发便利性巧妙地简化了分布式系统基础设施的开发,如服务发现注册 ...

  3. springcloud集成sentinel 《微服务》

    1.安装 1.1 docker安装 docker run --name sentinel -d -p 8858:8858 -p 8719:8719 -d bladex/sentinel-dashboa ...

  4. # SpringCloud集成 报错 An attempt was made to call a method that does not exist. The attempt was

    SpringCloud集成 报错 An attempt was made to call a method that does not exist. The attempt was made from ...

  5. 史上最简单:SpringCloud 集成 mybatis-plus(以若依微服务版本为例)

    编者按:若依微服务版是基于Spring Boot.Spring Cloud & Alibaba的微服务的权限管理系统,也是笔者比较推荐的个人学习和企业实践都比较优秀的开源项目. 笔者也以此项目 ...

  6. SpringCloud集成微信支付

    SpringCloud集成微信支付 参照文档地址 代码里面有注释替换自己的微信参数即可 里面的加密直接搜MD5,AES加解密就可以,随机生成字符串 然后配置文件配置一下回调地址还有微信支付参数就ok了 ...

  7. 不服不行啊,华为P8确实把SpringCloud集成Dubbo给一次性讲透了

    Spring Cloud集成Dubbo 目前Dubbo在国内还是有较多公司在使用的,一方面是因为Dubbo作为阿里巴巴开源的一个SOA服务治理解决方案,在国内发展较早,有比较好的先发优势:另一方面是因 ...

  8. spring-cloud集成数据库版本迁移工具flyway

    spring-cloud集成数据库版本迁移工具flyway Flyway实现数据库版本同步有两种方式,一种就是直接导包,通过配置文件使用,还有一种就是自定义的方式. 一 .依赖+配置文件 1 flyw ...

  9. SpringBootAdmin集成Turbine、使用Spring Boot Security添加安全验证

    SpringBootAdmin集成Turbine Hystrix Dashboard是一个监控熔断器状况的组件,而Turbine是一个可以聚合多个HystrixDashboard的组件.在Spring ...

最新文章

  1. 初识JavaScript Promises
  2. java 待在原页面 代码_现在java后台,只要修改一点点代码,前段页面就报500,必须重新登录才行?...
  3. 无法启动程序,因为计算机中丢失msvcr.dll
  4. 【bzoj4372】烁烁的游戏 动态点分治+线段树
  5. Vscode----热门插件超实用插件汇总(史上最全)
  6. 今年是SAP进入中国25周年,我从2007年毕业进入SAP成都研究院,也马上就待满14年了。
  7. 【ArcGIS遇上Python】从入门到精通系列之第一章:ArcGIS Python简介
  8. 将信号量代码生成静态库以及动态库
  9. 沉痛哀悼雷霄骅博士!
  10. Django基础三之视图函数
  11. php制作多媒体课件,网络自主学习型多媒体课件设计与制作PPT.ppt
  12. ThinkPad E431如何关闭触摸板
  13. tf7: RNN—古诗词
  14. 如何用matlab画北极熊,简笔画:如何使用Flash绘制北极熊,值得收藏
  15. 车载GPS设备对接java记录
  16. 计算机cpu风扇不转怎么办,如果计算机启动时cpu风扇不旋转,该怎么办?解决方法[详细说明]...
  17. myCat实现分库分表
  18. 记录93年男孩日常消费网店收入
  19. Android UI个性style
  20. 如何完成一份优秀的前端求职简历?

热门文章

  1. 计算机天天乐学题库C语言,天天乐学选择题(共1919小题)-有答案及解释.docx
  2. 记录 22.9.25 第312场周赛1~3
  3. STM32之flash读写操作篇
  4. 联想ThinkBook14+ i5独显版使用感受
  5. 【Linux】第十一章 进程信号(概念+产生信号+阻塞信号+捕捉信号)
  6. linux桌面版mint安装,在Linux Mint系统上安装Spotify桌面客户端的方法
  7. 小程序毕设作品之微信疫苗预约小程序毕业设计(6)开题答辩PPT
  8. CJS、ESM、AMD、CMD、UMD
  9. 【VBA研究】再论“找不到工程或库“ 解决方案
  10. [if IE] 在IE10 或者是 IE11以及以上 中无效的解决方案