SpelParseException: After parsing a valid expression, there is still more data in the expression: 'lcurly({)'

心已入冬 提交于 2020-05-14 18:52:45

问题


I am trying to condtionally create a component using @ConditionalOnExpression("not ${service.synchronous} && not ${service.disabled}").

I based this on Spring Boot SpEL ConditionalOnExpression check multiple properties, which provides a multi-property conditional as follows: @ConditionalOnExpression("${properties.first.property.enable:true} && ${properties.second.property.startServer:false}")

However, I keep getting:

Caused by: org.springframework.expression.spel.SpelParseException: EL1041E: After parsing a valid expression, there is still more data in the expression: 'lcurly({)'

Those properties are always set in my .properties file so I did not provide a default value with the colon notation. What am I doing wrong?


回答1:


In most such cases the properties your app is reading are not what you expect them to be.

Set a breakpoint on all constructors of SpelParseException. In the debugger you will see the expression that is parsed, that will give show you exactly which properties you are really using.

Maybe you have to go search a little in the stack until you find the right location where you can see the expression.




回答2:


You will need to provide the default values for your properties like in the example you followed, so update the expression to be:

@ConditionalOnExpression("not ${service.synchronous:false} && not ${service.disabled:true}")


来源:https://stackoverflow.com/questions/49714249/spelparseexception-after-parsing-a-valid-expression-there-is-still-more-data-i

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!