我创建了我新的自定义注释@MyCustomAnnotation自定义注释不会在Spring bean工作
@Target({ElementType.METHOD, ElementType.TYPE, ElementType.FIELD})
@Retention(RUNTIME)
public @interface MyCustomAnnotation{
}
我申请的组件和bean中的注释。下面是代码,
@MyCustomAnnotation
@Component
public class CoreBussinessLogicHandler implements GenericHandler<BussinessFile> {
//some bussiness logic
}
而且
@Configuration
public class BussinessConfig {
@Autowired
private CoreIntegrationComponent coreIntegrationComponent;
@MyCustomAnnotation
@Bean(name = INCOMING_PROCESS_CHANNEL)
public MessageChannel incomingProcessChannel() {
return coreIntegrationComponent.amqpChannel(INCOMING_PROCESS_CHANNEL);
}
//some other configurations
}
现在我想用@MyCustomAnnotation注释的所有豆子。因此,这里的代码,
import org.springframework.context.ApplicationContext;
@Configuration
public class ChannelConfig {
@Autowired
private ApplicationContext applicationContext;
public List<MessageChannel> getRecipientChannel(CoreIntegrationComponent coreIntegrationComponent) {
String[] beanNamesForAnnotation = applicationContext.getBeanNamesForAnnotation(MyCustomAnnotation.class);
//Here in output I am getting bean name for CoreBussinessLogicHandler Only.
}
}
我的问题是,为什么我没有名为“INCOMING_PROCESS_CHANNEL”越来越豆,因为它有@MyCustomAnnotation?如果我想获得名为'INCOMING_PROCESS_CHANNEL'的bean,我应该做些什么代码更改?