SpringCloud启动zuul时,报如下错误:
查询发现是Springboot的版本问题,我这里springbood版本是2.1.0,SpringCloud是F版本。把SpringBoot版本降到2.0.6即可。
2018-11-29 15:54:38.127 INFO 30532 --- [ main] com.java4all.ZuulServer1Application : No active profile set, falling back to default profiles: default
2018-11-29 15:54:38.789 WARN 30532 --- [ main] o.s.boot.actuate.endpoint.EndpointId : Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format.
2018-11-29 15:54:38.798 WARN 30532 --- [ main] o.s.boot.actuate.endpoint.EndpointId : Endpoint ID 'hystrix.stream' contains invalid characters, please migrate to a valid format.
2018-11-29 15:54:38.823 WARN 30532 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'counterFactory' defined in class path resource [org/springframework/cloud/netflix/zuul/ZuulServerAutoConfiguration$ZuulCounterFactoryConfiguration.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.netflix.zuul.ZuulServerAutoConfiguration$ZuulCounterFactoryConfiguration; factoryMethodName=counterFactory; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/netflix/zuul/ZuulServerAutoConfiguration$ZuulCounterFactoryConfiguration.class]] for bean 'counterFactory': There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.netflix.zuul.ZuulServerAutoConfiguration$ZuulMetricsConfiguration; factoryMethodName=counterFactory; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/netflix/zuul/ZuulServerAutoConfiguration$ZuulMetricsConfiguration.class]] bound.
2018-11-29 15:54:38.835 INFO 30532 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-11-29 15:54:38.837 ERROR 30532 --- [ 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:7509', transport: 'socket'
Process finished with exit code 1
2018-11-29 15:54:38.127 INFO 30532 — [ main] com.java4all.ZuulServer1Application : No active profile set, falling back to default profiles: default
2018-11-29 15:54:38.789 WARN 30532 — [ main] o.s.boot.actuate.endpoint.EndpointId : Endpoint ID ‘service-registry’ contains invalid characters, please migrate to a valid format.
2018-11-29 15:54:38.798 WARN 30532 — [ main] o.s.boot.actuate.endpoint.EndpointId : Endpoint ID ‘hystrix.stream’ contains invalid characters, please migrate to a valid format.
2018-11-29 15:54:38.823 WARN 30532 — [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name ‘counterFactory’ defined in class path resource [org/springframework/cloud/netflix/zuul/ZuulServerAutoConfiguration
Z
u
u
l
C
o
u
n
t
e
r
F
a
c
t
o
r
y
C
o
n
f
i
g
u
r
a
t
i
o
n
.
c
l
a
s
s
]
:
C
a
n
n
o
t
r
e
g
i
s
t
e
r
b
e
a
n
d
e
f
i
n
i
t
i
o
n
[
R
o
o
t
b
e
a
n
:
c
l
a
s
s
[
n
u
l
l
]
;
s
c
o
p
e
=
;
a
b
s
t
r
a
c
t
=
f
a
l
s
e
;
l
a
z
y
I
n
i
t
=
f
a
l
s
e
;
a
u
t
o
w
i
r
e
M
o
d
e
=
3
;
d
e
p
e
n
d
e
n
c
y
C
h
e
c
k
=
0
;
a
u
t
o
w
i
r
e
C
a
n
d
i
d
a
t
e
=
t
r
u
e
;
p
r
i
m
a
r
y
=
f
a
l
s
e
;
f
a
c
t
o
r
y
B
e
a
n
N
a
m
e
=
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
c
l
o
u
d
.
n
e
t
f
l
i
x
.
z
u
u
l
.
Z
u
u
l
S
e
r
v
e
r
A
u
t
o
C
o
n
f
i
g
u
r
a
t
i
o
n
ZuulCounterFactoryConfiguration.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.netflix.zuul.ZuulServerAutoConfiguration
ZuulCounterFactoryConfiguration.class]:Cannotregisterbeandefinition[Rootbean:class[null];scope=;abstract=false;lazyInit=false;autowireMode=3;dependencyCheck=0;autowireCandidate=true;primary=false;factoryBeanName=org.springframework.cloud.netflix.zuul.ZuulServerAutoConfigurationZuulCounterFactoryConfiguration; factoryMethodName=counterFactory; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/netflix/zuul/ZuulServerAutoConfiguration
Z
u
u
l
C
o
u
n
t
e
r
F
a
c
t
o
r
y
C
o
n
f
i
g
u
r
a
t
i
o
n
.
c
l
a
s
s
]
]
f
o
r
b
e
a
n
′
c
o
u
n
t
e
r
F
a
c
t
o
r
y
′
:
T
h
e
r
e
i
s
a
l
r
e
a
d
y
[
R
o
o
t
b
e
a
n
:
c
l
a
s
s
[
n
u
l
l
]
;
s
c
o
p
e
=
;
a
b
s
t
r
a
c
t
=
f
a
l
s
e
;
l
a
z
y
I
n
i
t
=
f
a
l
s
e
;
a
u
t
o
w
i
r
e
M
o
d
e
=
3
;
d
e
p
e
n
d
e
n
c
y
C
h
e
c
k
=
0
;
a
u
t
o
w
i
r
e
C
a
n
d
i
d
a
t
e
=
t
r
u
e
;
p
r
i
m
a
r
y
=
f
a
l
s
e
;
f
a
c
t
o
r
y
B
e
a
n
N
a
m
e
=
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
c
l
o
u
d
.
n
e
t
f
l
i
x
.
z
u
u
l
.
Z
u
u
l
S
e
r
v
e
r
A
u
t
o
C
o
n
f
i
g
u
r
a
t
i
o
n
ZuulCounterFactoryConfiguration.class]] for bean 'counterFactory': There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.netflix.zuul.ZuulServerAutoConfiguration
ZuulCounterFactoryConfiguration.class]]forbean′counterFactory′:Thereisalready[Rootbean:class[null];scope=;abstract=false;lazyInit=false;autowireMode=3;dependencyCheck=0;autowireCandidate=true;primary=false;factoryBeanName=org.springframework.cloud.netflix.zuul.ZuulServerAutoConfigurationZuulMetricsConfiguration; factoryMethodName=counterFactory; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/netflix/zuul/ZuulServerAutoConfiguration$ZuulMetricsConfiguration.class]] bound.
2018-11-29 15:54:38.835 INFO 30532 — [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2018-11-29 15:54:38.837 ERROR 30532 — [ 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 Z u u l C o u n t e r F a c t o r y C o n f i g u r a t i o n . c l a s s ] , c o u l d n o t b e r e g i s t e r e d . A b e a n w i t h t h a t n a m e h a s a l r e a d y b e e n d e f i n e d i n c l a s s p a t h r e s o u r c e [ o r g / s p r i n g f r a m e w o r k / c l o u d / n e t f l i x / z u u l / Z u u l S e r v e r A u t o C o n f i g u r a t i o n 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 ZuulCounterFactoryConfiguration.class],couldnotberegistered.Abeanwiththatnamehasalreadybeendefinedinclasspathresource[org/springframework/cloud/netflix/zuul/ZuulServerAutoConfigurationZuulMetricsConfiguration.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:7509’, transport: ‘socket’
Process finished with exit code 1