dubbo+zookeeper+hystrix整合springBoot
详细环境搭建可以看我前两篇文章,此文只简单介绍下融合Hystrix
传送门:
dubbo+zookeeper环境搭建
dubbo+zookeeper整合springBoot
介绍下整合Hystrix后需要修改的地方
1、pom.xml
在Consumer和Producer两个工程中的pom.xml文件都追加下面的依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<version>2.2.2.RELEASE</version>
</dependency>
如果启动项目有报错(如下错误),很大原因是因为上面引入的hystrix依赖版本和spring-boot的依赖版本不兼容(都找最新的版本即可)
java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:157)
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:98)
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:64)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(