package com.test.core.condition; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.kafka.annotation.KafkaListenerAnnotationBeanPostProcessor; import org.springframework.stereotype.Component; @Component @Slf4j public class KafkaBeanDefinitionRegistryPostProcessor extends KafkaListenerAnnotationBeanPostProcessor { @Value("${spring.profiles.active}") private String environment; private final String UAT="uat"; private final String PROD="prod"; @Override public Object postProcessAfterInitialization(Object bean, String beanName) {
//只在UAT和PROD下消费数据 if (UAT.equals(environment)||PROD.equals(environment)) { return bean; } return null; } }
标签:消费,String,UAT,private,Kafka,environment,springframework,本地,import From: https://www.cnblogs.com/tiancai/p/17282899.html