首先需要在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