The bean 'counterFactory', could not be registered

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/chen_2890/article/details/84872455

问题:

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

Description:

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.

Action:

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


Process finished with exit code 1

原因:

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

	<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-zuul -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-zuul</artifactId>
            <version>2.0.2.RELEASE</version>
        </dependency>

解决方案:

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

猜你喜欢

转载自blog.csdn.net/chen_2890/article/details/84872455