The bean '.FeignClientSpecification', defined in null, could not be registered. A bean with that nam

错误信息:

Description:

The bean 'sxbs-mall3.FeignClientSpecification', defined in null, could not be registered. A bean with that name has already been defined in null and overriding is disabled.
截图:

 .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.1.RELEASE)

2019-06-12 18:13:07.532  INFO 50064 --- [  restartedMain] The following profiles are active: dev
2019-06-12 18:13:07.994  WARN 50064 --- [  restartedMain] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'sxbs-mall3.FeignClientSpecification' defined in null: Cannot register bean definition [Generic bean: class [org.springframework.cloud.openfeign.FeignClientSpecification]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] for bean 'sxbs-mall3.FeignClientSpecification': There is already [Generic bean: class [org.springframework.cloud.openfeign.FeignClientSpecification]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] bound.
2019-06-12 18:13:07.999  INFO 50064 --- [  restartedMain] 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-06-12 18:13:08.001 ERROR 50064 --- [  restartedMain] 

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'sxbs-mall3.FeignClientSpecification', defined in null, could not be registered. A bean with that name has already been defined in null and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.772 s
[INFO] Finished at: 2019-06-12T18:13:08+08:00
[INFO] ------------------------------------------------------------------------

Process finished with exit code 0

原因:
springCloud 的2.1.0以上版本的,将不再默认支持 FeignClient 的name属性 的相同名字。 
即 :多个接口上的@FeignClient(“相同服务名”)会报错,overriding is disabled(覆盖 是 禁止的/关闭的)。

解决: 开启 覆盖 就行

spring:
    application:
      name: sxbs-mall-consumer
    # 多个接口上的@FeignClient(“相同服务名”)会报错,overriding is disabled。
    # 设置 为true ,即 允许 同名
    main:
      allow-bean-definition-overriding: true

 

你可能感兴趣的:(springCloud,java,springBoot)