0

我正在使用 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}'
4

1 回答 1

0

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

于 2012-07-16T13:01:53.613 回答