SpEL

Spriing boot stater中根据配置文件中的条件 生成相应的bean, 以适应不同场景

@ConditionalOnExpression中使用SpEl,  支持各种条件表达式

String的各种方法都能用,不限于等于、正则、以..开始、以..结束


自已如何用?

MethodBasedEvaluationContext context = new MethodBasedEvaluationContext(null, method, args, discoverer);
Object id = parser.parseExpression('#xxxxxxx.xxx').getValue(context);

参考

https://docs.spring.io/spring/docs/4.3.10.RELEASE/spring-framework-reference/html/expressions.html

https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-auto-configuration.html#boot-features-spel-conditions

posted @ 2018-10-23 12:46  funny_coding  阅读(153)  评论(0编辑  收藏  举报
build beautiful things, share happiness