Spring-cloud-netflix: How to check two condition while using @ConditionalOnProperty or @ConditionalOnExpression

Created on 15 Mar 2016  路  2Comments  路  Source: spring-cloud/spring-cloud-netflix

Hi, I need to check two condition('AND'(both the condition should be satisfied)) on yml file while creating a bean. How do i do that, as @ConditionalOnProperty supports only one property configuration.

Most helpful comment

I ended up here searching for a solution to this problem so here is the solution.

@ConditionalOnExpression("${properties.first.property.enable:true} && ${properties.second.property.startServer:false}")

Check here for more info: http://stackoverflow.com/questions/40477251/spring-boot-spel-conditionalonexpression-check-multiple-properties/40497419#40497419

All 2 comments

Closing as that is a spring-boot question, try asking here http://stackoverflow.com/questions/tagged/spring-boot

I ended up here searching for a solution to this problem so here is the solution.

@ConditionalOnExpression("${properties.first.property.enable:true} && ${properties.second.property.startServer:false}")

Check here for more info: http://stackoverflow.com/questions/40477251/spring-boot-spel-conditionalonexpression-check-multiple-properties/40497419#40497419

Was this page helpful?
0 / 5 - 0 ratings