1.依赖
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile group: 'org.springframework.kafka', name: 'spring-kafka'
compile group: 'org.apache.kafka', name: 'kafka-streams'
/* 事务拦截 */
compile('org.springframework.boot:spring-boot-starter-aop')
compile group: 'org.springframework', name: 'spring-aspects', version: "${springAspectsVersion}"
}
2.配置
application.yml
spring:
devtools:
restart:
enabled: false
kafka:
#作为消费者的配置
consumer:
#客户端ID
client-id: consumer${random.int(0,1000)}
#组ID
group-id: demo
#kafka引导服务配置
bootstrap-servers: localhost:9092
#向服务器提交消费者偏移量
enable-auto-commit: true
auto-commit