The bean 'counterFactory', could not be registered

拼搏现实的明天。 2022-04-08 08:41 324阅读 0赞

问题:

在springboot下配置好zuul的依赖后,启动报错:

  1. Description:
  2. The bean 'counterFactory', defined in class path resource [org/springframework/cloud/netflix/zuul/ZuulServerAutoConfiguration$ZuulCounterFactoryConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/cloud/netflix/zuul/ZuulServerAutoConfiguration$ZuulMetricsConfiguration.class] and overriding is disabled.
  3. Action:
  4. Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
  5. Process finished with exit code 1

原因:

springboot和zuul的版本不兼容,springboot版本太高了,zuul的版本相对低很多

  1. <parent>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-starter-parent</artifactId>
  4. <version>2.1.1.RELEASE</version>
  5. <relativePath/> <!-- lookup parent from repository -->
  6. </parent>
  7. <!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-zuul -->
  8. <dependency>
  9. <groupId>org.springframework.cloud</groupId>
  10. <artifactId>spring-cloud-starter-netflix-zuul</artifactId>
  11. <version>2.0.2.RELEASE</version>
  12. </dependency>

解决方案:

更换springboot版本为2.0.5或2.0.6,可以正常运行。

原来微信打赏还可以备注哦

在这里插入图片描述

发表评论

表情:
评论列表 (有 0 条评论,324人围观)

还没有评论,来说两句吧...

相关阅读