一、创建BaiduCenterFeignClient
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
@FeignClient(name = "baidu",url = "https://www.baidu.com/")
public interface BaiduCenterFeignClient {
@GetMapping("/baidu")
String getBaidu();
}
二、调用
@Autowired
BaiduCenterFeignClient baiduCenterFeignClient;
@GetMapping("/test")
public String getBaidu(){
return baiduCenterFeignClient.getBaidu();
}