it绿萝 - 云代码空间
——
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix</artifactId> </dependency>2、在application.java类中加入@EnableCircuitBreaker断路器注解。
@RestController @DefaultProperties(groupKey = "hello-groupKey", commandProperties = { // 超时时间(毫秒) @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "2000") }, threadPoolProperties = { // 最大线程数 @HystrixProperty(name = "coreSize", value = "2") }) public class MyRestController { @Autowired private IService iService; @GetMapping(value = "/hello", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @HystrixCommand(fallbackMethod = "helloFallback", commandKey = "hello-commandKey") public String hello() throws InterruptedException { Thread.sleep(3000); String hello = iService.hello(); return "hello: " + hello; } public String helloFallback() { return "helloFallback"; } }微服务java b2b商城系统_java商城源码100%开源适合2次开发