My feign client class is as below along with the Application class.
@FeignClient(name = "ExampleService", configuration = FeignClientConfig.class, url = "http://localhost:8091")
public interface ExampleClient {
@GetMapping(value = "exampleService/exampleDetails/{id}")
public List<ExampleDTO> getExampleDetails(@PathVariable(name = "id") final Long id);
}
@EnableAutoConfiguration
@EnableScheduling
@SpringBootApplication
@EnableFeignClients(basePackages = {"com.package.example"})
@ComponentScan(basePackages = {"com.package"})
public class ExampleApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(ExampleApplication.class, args);
}
}
In the above code I'm getting the error as given below
APPLICATION FAILED TO START
Description:
The bean 'ExampleService.FeignClientSpecification' could not be registered. A bean with that name has already been defined and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding = true
First of all, there's only 1 feign client by that name being defined in the project. Second I tried giving it a context ID just in case there was a bean with the same name being defined somewhere I must've missed.
@FeignClient(contextId = "myExampleService", name="ExampleService", configuration = FeignClientConfig.class, url = "http://localhost:8091")
but again it gave me the same error
The bean 'myExampleService.FeignClientSpecification' could not be registered. A bean with that name has already been defined and overriding is disabled.
Third, I also tried by giving the property in application.properties file for overriding the bean
spring.main.allow-bean-definition-overriding = true
but still I'm getting the same error. Any reason why I'm getting this issue even though there is only 1 bean with the name available for Spring's app context?