赞
踩
【问题描述】: ApplicationContextException: Failed to start bean ‘org.springframework.kafka.config.internalKafkaListenerEndpointRegistry’; nested exception is java.lang.IllegalStateException: No group.id found in consumer config, container properties, or @KafkaListener annotation; a group.id is required when group management is used.
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:185)
at org.springframework.context.support.DefaultLifecycleProcessor.access
200
(
D
e
f
a
u
l
t
L
i
f
e
c
y
c
l
e
P
r
o
c
e
s
s
o
r
.
j
a
v
a
:
53
)
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
c
o
n
t
e
x
t
.
s
u
p
p
o
r
t
.
D
e
f
a
u
l
t
L
i
f
e
c
y
c
l
e
P
r
o
c
e
s
s
o
r
200(DefaultLifecycleProcessor.java:53) at org.springframework.context.support.DefaultLifecycleProcessor
200(DefaultLifecycleProcessor.java:53)atorg.springframework.context.support.DefaultLifecycleProcessorLifecycleGroup.start(DefaultLifecycleProcessor.java:360)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158)
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:894)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
at com.yunda.BootbaseApplication.main(BootbaseApplication.java:23)
Caused by: java.lang.IllegalStateException: No group.id found in consumer config, container properties, or @KafkaListener annotation; a group.id is required when group management is used.
at org.springframework.util.Assert.state(Assert.java:73)
at org.springframework.kafka.listener.AbstractMessageListenerContainer.checkGroupId(AbstractMessageListenerContainer.java:399)
at org.springframework.kafka.listener.AbstractMessageListenerContainer.start(AbstractMessageListenerContainer.java:335)
at org.springframework.kafka.config.KafkaListenerEndpointRegistry.startIfNecessary(KafkaListenerEndpointRegistry.java:312)
at org.springframework.kafka.config.KafkaListenerEndpointRegistry.start(KafkaListenerEndpointRegistry.java:257)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:182)
… 14 common frames omitted
【解决方案】: 监听的类需要添加消费者所属的组名 groupId = “自行定义”
1 @KafkaListener(groupId = "xxx", topics = {ENTRY_TOPIC_NAME},containerFactory="stringkafkaListenerContainerFactory")
2 public void revice(String data) throws Exception {
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。