我想通過使用緩存抽象文檔中的方法來訪問自定義密鑰生成器來生成緩存的密鑰,但直到現在我還沒有找到任何解決方案...在這裏我給我的代碼反映方法的彈簧緩存
@Cacheable(value = "itemsCache", key ="T(com.ernst.transactionsAPI.IndexKeyGenerator).generate(#root.target, #root.method.name, #root.args[0])")
public List<FilialenImpl> getOutletByCustomSearchCache(SearchParametersImpl searchParameters);
和我收到以下錯誤:
org.springframework.expression.spel.SpelEvaluationException: EL1004E:(pos 47): Method call: Method generate(com.ernst.transactionsImpl.filialen.FilialenServiceBean,java.lang.String,com.ernst.persistenceImpl.impl.SearchParametersImpl) cannot be found on com.ernst.transactionsAPI.IndexKeyGenerator type
它不是反映了方法的名稱,但其傳遞的方法type..can任何一個請如何解決這個問題。在indexkeygenerator
方法看起來提前像
public Object generate(Object target, Method method, Object... params) {
...}
感謝,
問候, 拉哈西克哈。
一些盲目的猜測:你傳遞一個方法名稱(一個字符串),其中一個方法是預期的;你正在調用一個類的非靜態方法。 –
實際上我已經使用了spel上下文來傳遞一個方法(即#root.method.name)..但是它並沒有像我期待的那樣發生。 – user503285
也許你可以看看[這個問題](http://stackoverflow.com/q/14259165/1225328),你可以找到一些有趣的東西來解決你面臨的問題。 – sp00m