spring boot 2.2 jdk 13
@FeignClient(contextId = "sp-producer-hystrix",name="SPRINGCLOUD-PRODUCER/producer",fallback= FeignHystrixFallback.class)
public interface CusFeignHystrix extends CustomFeignHystrix {
}
@RequestMapping("/feignHystrix")
public interface CustomFeignHystrix {
@GetMapping("/usl")
public List<User> usl();
}
@Component
public class FeignHystrixFallback implements CusFeignHystrix {
protected Logger logger = LoggerFactory.getLogger(getClass());
@Override
public List<User> usl() {
logger.error("defeat--------------------------");
User temp = new User();
temp.setName("defeat+++++++++++++++++");
return List.of(temp);
}
}
Error at startup
Ambiguous mapping. Cannot map 'com.ciel.springcloudfathernewconsumer0.service.CusFeignHystrix' method
com.ciel.springcloudfathernewconsumer0.service.CusFeignHystrix#usl()
to {GET /feignHystrix/usl}: There is already 'feignHystrixFallback' bean method
I had to remove @Component
from FeignHystrixFallback
But it happened
No fallback instance of type class com.ciel.springcloudfathernewconsumer0.fallback.FeignHystrixFallback found for feign client sp-producer-hystrix
I finally solved it like this ;
Overriding @GetMapping ("/usl")
with @GetMapping ("/ gg")
@Component
public class FeignHystrixFallback implements CusFeignHystrix {
protected Logger logger = LoggerFactory.getLogger(getClass());
@Override
@GetMapping("/gg")
public List<User> usl() {
logger.error("defeat--------------");
User temp = new User();
temp.setName("defeat+++++++++++++++++");
return List.of(temp);
}
}
Comment From: cielswift
I think this is a bug
Comment From: mbhave
Spring Cloud Feign is a separate project with its own issue tracker. If you believe you've found a bug, please open an issue there with a minimal sample that the team can run to reproduce the issue.
Comment From: cielswift
But this is only a problem when integrating with springboot
Comment From: philwebb
@cielswift You'll still need to raise the issue with Spring Cloud Feign first. We don't have any code to support Feign in Spring Boot. I'd suggest attaching a sample application to your issue is possible.