package com.test.core.condition; import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.rabbit.annotation.RabbitListenerAnnotationBeanPostProcessor; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @Component @Slf4j public class RabbitMQBeanDefinitionRegistryPostProcessor extends RabbitListenerAnnotationBeanPostProcessor { @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,RabbitMQ,environment,springframework,本地,org,import From: https://www.cnblogs.com/tiancai/p/17282897.html