What Bianca supposed to do is to add a @Service annotated class to her project where she can use @cacheable annotation.
The traditional way to use FeignClient is to have only an interface annotated with @FeignClient, and then call these methods form other projects/classes. She has added a @Service annotated class, where she call her feignclients methods caching whatever she want.
Traditional:
FeignClient class:
@FeignClient(name="my_feign-client", url = "http://myurl.com/")
public interface MyFeignClient {
@GetMapping("/test")
public ResponseEntity<String> test() throws FeignException;
Class where to call feign client method:
public class TestClass {
@Autowired
private MyFeignClient myFeignClient ;
public String callTest() {
...
return myFeignClient.test();
}
Bianca's method:
Feign client class remains the same.
Service class with cache:
@Service
@CacheConfig(cacheNames={"test"})
public class TestService {
@Autowired
private MyFeignClient myFeignClient ;
@Cacheable
public String callCachedTest() {
...
return myFeignClient.test();
}
And last, the class to call the cached method, that call feignClient:
public class TestClass {
@Autowired
private TestService testService ;
public String callTest() {
...
return testService.callCachedTest();
}