Spring Boot @Conditional注释被忽略

时间:2017-08-09 19:58:59

标签: spring spring-boot annotations

我正在尝试根据某些属性(条件)启用调度程序,但它会忽略我的@Conditional注释而不考虑条件结果。有什么建议吗?

条件类

public class SchedulerCondition implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        return property#1 || property#2
    }

}

配置类

 @Configuration
 public class Scheduler {

    @Conditional(SchedulerCondition.class)
    @Bean(name = TaskManagementConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME)
    @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
    public void processJobs() {
        ......
    }
}

0 个答案:

没有答案