2017-09-08 35 views
0

在我的Java項目中,我將spring遷移到 - > 4.3.4,並將ehcache-spring-annotation遷移到http://www.springframework.org/schema/cacheSpring 4 @cacheable註解:如何爲自定義密鑰生成器添加屬性?

我有問題,我的定義緩存customkeygenerator的屬性:

@Cacheable(value = "cacheDAO", keyGenerator = @KeyGenerator(name = "CacheKeyGenerator", 
     properties = { @Property(name = "useReflection", value = "true"), 
         @Property(name = "checkforCycles", value = "true"), 
         @Property(name = "includeMethod", value = "false") }) 

似乎不可能由@keyGenerator註釋來定義useReflection,checkForCycles或includeMethod。

你能幫我配置嗎?春天4怎麼樣? 請告訴我,如果你不明白我的問題。

謝謝!

回答

0

根據the documentation,似乎不可能內聯。然而,使用相同的密鑰生成器配置特定的bean,但將不同的屬性值映射到不同的bean名稱是非常簡單的。然後你引用@Cacheable註釋中的確切一個。