Java 豆子';exampleService.FaignClientSpecification';无法注册。已定义Bean,并且已禁用重写

Java 豆子';exampleService.FaignClientSpecification';无法注册。已定义Bean,并且已禁用重写,java,spring,spring-boot,spring-cloud-feign,Java,Spring,Spring Boot,Spring Cloud Feign,我的假客户机类和应用程序类如下所示 @FeignClient(name = "ExampleService", configuration = FeignClientConfig.class, url = "http://localhost:8091") public interface ExampleClient { @GetMapping(value = "exampleService/exampleDetails/{id}") public List<ExampleDTO&g

我的假客户机类和应用程序类如下所示

@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);
  }
}
首先,项目中只定义了一个同名的外国客户机。 第二,我尝试给它一个上下文ID,以防在我一定错过的地方定义了一个同名的bean

@FeignClient(contextId = "myExampleService", name="ExampleService", configuration = FeignClientConfig.class, url = "http://localhost:8091")
但它又给了我同样的错误

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

第三,我还尝试在application.properties文件中提供属性以覆盖bean

spring.main.allow-bean-definition-overriding = true
但我还是犯了同样的错误。
尽管Spring的应用程序上下文中只有一个名为bean的bean,但为什么我会遇到这个问题?

我也遇到了同样的问题

对我来说,这是一个maven的问题,似乎使用了同一个库的两个副本(不是因为真正的问题,而是因为maven“感到困惑”。我一直在maven安装库的本地版本)


我通过删除我的C:\Users{user}.m2\存储库,然后重新导入项目,解决了这个问题

如果您使用相同的名称定义了多个@FeignClients,也会发生这种情况:


在我的客户中给出唯一的名字为我解决了这个问题

嗨,伙计们,我也面临着同样的问题。有没有人对这一点有什么建议。亲爱的,@VikramPathania我已经添加了一个答案,为我解决了这个问题,至少这个问题解决了吗?现在有同样的问题
spring.main.allow-bean-definition-overriding = true