【发布时间】:2019-06-27 18:04:00
【问题描述】:
Hystrx 断路器不会从 application.yml 文件中选择值。我需要从 application.yml 文件中获取 timeoutInMilliseconds、errorThresholdPercentage。当我运行程序时,这些属性没有影响,因为它们没有被拾取。
import java.net.URI;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
@Service
public class BookService {
RestTemplate restTemplate;
//Calling the service
@HystrixCommand
public String readingList(int flag) {
restTemplate = new RestTemplate();
URI uri = URI.create("http://localhost:8090/recommended/"+flag);
return this.restTemplate.getForObject(uri, String.class);
}
public String reliable(int flag) {
return "Cloud Native Java (O'Reilly)";
}
}
这是 application.yml 文件
hystrix:
command:
reliable:
execution:
isolation:
thread:
timeoutInMilliseconds: 6000
strategy: SEMAPHORE
circuitBreaker:
errorThresholdPercentage: 70
【问题讨论】:
标签: spring-boot hystrix