1. 程式人生 > >Spring框架註解指南

Spring框架註解指南

@Service public class BookService { private final RestTemplate restTemplate; public BookService(RestTemplate rest) { this.restTemplate = rest; } @HystrixCommand(fallbackMethod = "newList") public String bookList() { URI uri = URI.create("http://localhost:8081/recommended"); return this.restTemplate.getForObject(uri, String.class); } public String newList() { return "Cloud native Java"; } }