Search code examples
javafeign

@FeignClient interface in application's one dependency and @EnableFeignClients on application main class can't load the interface as bean


For example:

Application A -> dependency B. B got a @FeignClient annotated SPI interface, which is @Autowired depended by classes both in A and B, the SPI is expected to be works fine when application A is started.

Adding @EnableFeignClients and @SpringBootApplication(scanBasePackages= "path-include-that-SPI-interface") on A's main class and start, encounters an exception that "Cannot find bean qualified... [SPI interface]".


Solution

  • The solution is configuring scan base-path for @EnableFeignClients: @EnableFeignClients(basePackages= "path-include-that-SPI-interface").