@EnableFeignClients(clients = ...) enables the user to specify the exact @FeignClient interfaces that are supposed to be initialized and used. However, when the interfaces have the following structure:

basepackage.ClientA basepackage.subpackage.ClientB

Then @EnableFeignClients(clients = {ClientA.class, ClientB.class}) causes ClientB to be initialized twice, resulting in the following error:

"The bean could not be registered. A bean with that name has already been defined and overriding is disabled."

The cause of this seems to be that resolver scans both basepackage and basepackage.subpackage recursively, and finds ClientB both times.

Spring cloud version: Hoxton.SR4.

Attached a minimal spring boot app demonstrating the problem. feign-classes-demo.zip

Comment From: spencergibb

The clients attribute should disable scanning all together

Comment From: apodalyuk

It should, but it actually doesn't. Check out https://github.com/spring-cloud/spring-cloud-openfeign/blob/master/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsRegistrar.java#L182-L222 - clients adds a more sophisticated filter then proceeds with the same package scanning.

Comment From: spencergibb

Silly me 😬

Comment From: OlgaMaciaszek

Fix merged.