Consider following snippet, I am trying to call a method of propertiesContainer which would be used as a key.
@Cacheable(value = EhCacheManagerApi.CACHE_X_TOKEN, key = ("#{propertiesContainer.getId()}"))
public String getToken(PropertiesContainer propertiesContainer)
I cannot seem to figure out the correct spel expression for key, current format gives me:
org.springframework.expression.spel.SpelParseException: EL1043E:(pos 1): Unexpected token. Expected 'identifier' but was 'lcurly({)'
Before I tried key = ("#propertiesContainer.id") and key = ("#propertiesContainer.getId()")
propertiesContainer is an interface which has method getId returning String.
So presumably this is not the same as bean method invocation with SpEL?
Did you try the pure expression without the parenthesis:
This works for me in Spring 4.3.3 where PropertiesContainer is an interface with a getId() method.
Also, you might need to use
#p0.idinstead of the method parameter name if you don't have debug info in your compiled code. See the accepted answer here but that would give you a different error I suspect.