lundi 2 mars 2015

Spring caching - How to reference a bean in SPEL to enable conditional caching via @Cacheable

I've got a method that I want to conditionally cache based on the result of a method call to another bean (which says whether or not global caching is turned on).


I've tried,using SpEL, something along the lines of



@Cacheable(condition="@someBean.isSomeBoolean()")


which requires a BeanResolver which I don't have configured. I'm OK about creating one of these programmatically but how do I configure the class I've got cacheable methods in to reference this ? The error I am currently getting is:



No bean resolver registered in the context to resolve access to bean


There's a similar post here talking about keys, not conditions.


Has anyone successfully managed to reference other beans in caching annotations ?


Aucun commentaire:

Enregistrer un commentaire