我正在尝试使用 @ConditionalOnExpression("not ${service.synchronous} && not ${service.disabled}")
有条件地创建一个组件.
我基于 Spring Boot SpEL ConditionalOnExpression check multiple properties ,它提供了如下的多属性条件:@ConditionalOnExpression("${properties.first.property.enable:true} && ${properties.second.property.startServer:false}")
但是,我不断收到:Caused by: org.springframework.expression.spel.SpelParseException: EL1041E: After parsing a valid expression, there is still more data in the expression: 'lcurly({)'
这些属性总是在我的 .properties 文件中设置,所以我没有提供带有冒号符号的默认值。我究竟做错了什么?
最佳答案
您需要为您的属性提供默认值,就像您遵循的示例一样,因此将表达式更新为:
@ConditionalOnExpression("not ${service.synchronous:false} && not ${service.disabled:true}")
关于spring - SpelParseException : After parsing a valid expression, 表达式中还有更多数据: 'lcurly({)',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49714249/