Hystrix支付测服务降级fallback

1.pom文件

 

<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>

2.YML文件

 

server:
port: 8001
spring:
application:
name: cloud-provider-hystrix-payment #服务名
eureka:
client:
#表示是否将自己注册进EurekaServer默认为true
register-with-eureka: true
#是否从EurekaServer抓取已有的注册信息,默认为true,单节点无所谓,集群必须设置为true才能配合ribbon使用负载均衡
fetch-registry: true
service-url:
defaultZone: http://eureka7001.com:7001/eureka,http://eureka7002.com:7002/eureka #集群版
#defaultZone: http://localhost:7001/eureka 单机版

3. 启动类

 

@SpringBootApplication
@EnableEurekaClient
@EnableCircuitBreaker
public class PaymentMainHystrix8001 {
public static void main(String[] args) {
SpringApplication.run(PaymentMainHystrix8001.class,args);
}
}

4,业务类

 

5. 控制层



5. 控制层

原文地址:https://www.cnblogs.com/fuqiang-zhou/p/12612213.html