首先需要在Application應用啓動中需添加@EnableFeignClients註解。
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(value = "com.xxx.service")
public class XXXApplication {
public static void main(String[] args) {
SpringApplication.run(XXXApplication.class,args);
}
}
使用FeignClients調用服務場中的註冊的微服務
@FeignClient(value = "XXX-SERVER")
public interface FeignService {
@RequestMapping(value = "/xxx/check_token",method = RequestMethod.GET)
String getUser(@RequestParam(value = "token", required = true) String token);
}
參考資料:
https://blog.csdn.net/ZYC88888/article/details/81291684