【问题标题】:Assigning property value to an Annotation value in Spring在 Spring 中将属性值分配给 Annotation 值
【发布时间】:2012-04-14 04:27:25
【问题描述】:

我正在使用 ehcache-spring-annotations 和 @Cacheable 注释(我会在 Spring 3.1 中使用新的 @Cacheable,但它并没有提供我需要的所有东西)。

我想将 cacheName 变量设置为属性文件中条目的值,但如果我尝试使用 EL 表示法,它会将其读取为文字字符串。有没有办法解决这个问题?

@Cacheable(cacheName = "${connectionCacheName}")
public MyConnection getMyConnection(String id) {
return new MyConnection(id);
}

在 .properties 文件中...

connectionCacheName=myConnectionCache

例外:

Caused by: com.googlecode.ehcache.annotations.CacheNotFoundException: Unable to find cache '${connectionCacheName}'

【问题讨论】:

    标签: spring ehcache spring-annotations


    【解决方案1】:

    这个问题是由于我的属性占位符在 Spring 中没有正确配置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-23
      • 1970-01-01
      • 2018-09-01
      • 2019-04-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多