SpringCloud Finchley.SR2中 zuul 的使用与 SpringBoot 2.1.0版本不兼容问题

问题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-11-12 11:08:43.919 ERROR 32936 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :

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

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

Disconnected from the target VM, address: '127.0.0.1:60894', transport: 'socket'

原因

SpringBootSpringCloud 的版本不兼容造成。

这里因为 SpringBoot 使用了最新 2.1.0,而 SpringCloud 用的是 Finchley.SR2,而它支持的是 2.0.x 及以下版本(官方说明最高到 2.0.6 )。

解决

SpringBoot 版本到 2.0.x 或者使用 SpringCloud Greenwich.M1