是否可以使用SpEL将属性列表注入到@KafkaListner注解中?
大概是这样的
@KafkaListener(topics = "topic-name",
containerFactory = "myContainerFactory",
groupId = "group-id",
properties = "#{kafka.consumer.custom.properties}")
public void onMessage(String msg) {
log.info(msg);
}
application.yml
kafka:
consumer:
custom:
properties:
key.deserializer: org.apache.kafka.common.serialization.IntegerDeserializer
value.deserializer: org.apache.kafka.common.serialization.StringDeserializer
1条答案
按热度按时间cx6n0qe31#
请参见https://github.com/spring-projects/spring-kafka/issues/1880#issuecomment-887677779