【问题标题】:Grails - using Spring el expressions in Spring 3.1's @CacheableGrails - 在 Spring 3.1 的 @Cacheable 中使用 Spring el 表达式
【发布时间】:2012-04-10 08:58:46
【问题描述】:

我们计划使用 Spring 3.1 缓存抽象而不是 Grails Spring 缓存插件。我在本地尝试过,但是在使用 Spring el 表达式时出现了问题,例如

@Cacheable(value = 'dashboardCache', key = 'sessionStorageService.getUser()', condition = 'sessionStorageService.getUser() != null')
public List<BusinessDashboard> getUserDashboards(String serverName, SessionStorageService sessionStorageService) { ... }

执行集成测试用例时出现以下错误

EL1008E:(pos 0): Field or property 'sessionStorageService' cannot be found on object of type 'org.springframework.cache.interceptor.CacheExpressionRootObject'
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Field or    property 'sessionStorageService' cannot be found on object of type 'org.springframework.cache.interceptor.CacheExpressionRootObject'

我认为这种行为是由于缺少调试信息引起的——因此我的问题是:

是否可以在 Grails 应用程序中启用 Spring el 表达式,或者在编译过程中是否有任何参数告诉 Grails 将调试符号保留在类文件中?

(我们在 Grails 2.0.1 上运行)

【问题讨论】:

    标签: spring caching grails groovy


    【解决方案1】:

    你应该试试 '#sessionStorageService.getUser()'

    【讨论】:

      猜你喜欢
      • 2012-12-25
      • 2011-12-20
      • 1970-01-01
      • 1970-01-01
      • 2018-11-05
      • 2018-06-05
      • 2012-02-21
      • 2012-05-07
      • 1970-01-01
      相关资源
      最近更新 更多