How to check two condition while using @ConditionalOnProperty or @ConditionalOnExpression

后端 未结 4 1353
面向向阳花
面向向阳花 2020-12-14 16:50

I need to check that two conditions are satisfied on a YAML property file, while creating a bean. How do I do that, as the @ConditionalOnProperty annotation sup

4条回答
  •  天涯浪人
    2020-12-14 17:22

    Use @ConditionalOnExpression annotation and SpEL expression as described here http://docs.spring.io/spring/docs/current/spring-framework-reference/html/expressions.html.

    Example:

    @Controller
    @ConditionalOnExpression("${controller.enabled} and ${some.value} > 10")
    public class WebController {
    

提交回复
热议问题