Annotation @EnableFeignClients not working from @Configuration classes. Works fine from Spring Boot Application class, fails from Configuration class.
See: https://github.com/sfg-beer-works/sfg-brewery-beer-service/tree/enable-feign-on-config
Master branch working, branch enable-feign-on-config fails. (Bean not found error for Feign client).
Annotated config class is guru.sfg.brewery.beer_service.config.LocalDiscovery.
Use case is setting up config without Eureka using RestTemplate for local dev, and a config with Eureka via active profiles. Based on the Javadoc of the annotation, I expected this to work from configuration classes.
Also, tested locally using 2.2.1.RELEASE of the Spring Boot starter, same result. (Example is a minor release or two behind)
Comment From: appserzh
Hi.
I have faced the same problem.
This is because the configuration and clients are in different packages.
In such a situation, it is necessary to indicate where the clients are located:
@EnableFeignClients(basePackages = "guru.sfg.brewery.beer_service.services.inventory")
or list them explicitly:
@EnableFeignClients(clients = InventoryServiceFeignClient.class)
Comment From: OlgaMaciaszek
@springframeworkguru since the workaround mentioned by @appserzh is easy to use, I don't think there's a need to change that.
@appserzh would you like to create a PR adding this to the docs (against the 2.2.x branch)?
Comment From: OlgaMaciaszek
@ManasviGoyal is working on this issue.
Comment From: ManasviGoyal
@OlgaMaciaszek please check
Comment From: OlgaMaciaszek
Done.