spring - SpelParseException : After parsing a valid expression, 表达式中还有更多数据: 'lcurly({)'

标签 spring spring-el

我正在尝试使用 @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/

相关文章:

spring - Mockito 的 when() 方法无法正常工作

java - 将消息保留在队列中以防接收器崩溃

java - ClassPathXmlApplicationContext 错误,Spring 框架

java 8 spring spEL 可重复绑定(bind)减慢每次迭代

java - 为什么当我在 SpEL 中使用 java.util.Random 时会出现 SpelEvaluationException?

java - SPEL 在 KafkaListener 中不起作用。无法解决属性(property)问题

java - Spring中使用MappingMediaTypeFileExtensionResolver的 protected 方法的问题

java - 应用 @ResponseBody 时出现循环 View 路径错误

spring-boot - 在@Document indexName 中使用的 SpEL 与 spring 数据 elasticsearch 和 spring boot 没有被解析

java - xml 文件中的 Spring 表达式语言扩展