成功解决java.lang.IllegalStateException:Another strategy was already registered.

  • 项目场景:
  • 问题描述:
  • 原因分析:
  • 解决方案:
      • 参考文章

**

项目场景:

项目场景:微服务项目使用了熔断器Hystrix配置,在添加spring-boot-starter-actuator依赖之后报错。

问题描述:

异常关键内容描述:
Caused by: java.lang.IllegalStateException: Another strategy was already registered.

控制台打印异常如下:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hystrixConfig': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Another strategy was already registered.
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160) ~[spring-beans-5.2.12.RELEASE.jar:5.2.12.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:415) ~[spring-beans-5.2.12.RELEASE.jar:5.2.12.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1786) ~[spring-beans-5.2.12.RELEASE.jar:5.2.12.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.2.12.RELEASE.jar:5.2.12.RELEASE]
	......
Caused by: java.lang.IllegalStateException: Another strategy was already registered.
	at com.netflix.hystrix<