簡體   English   中英

Spring 4 @cacheable注解:如何為自定義密鑰生成器添加屬性?

[英]Spring 4 @cacheable annotation : how add properties for custom key generator?

在我的Java項目中,我將spring遷移到-> 4.3.4,並將ehcache-spring-annotation遷移到http://www.springframework.org/schema/cache

我在定義緩存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。

您能幫我配置一下嗎? Spring 4的工作方式如何? 如果您不明白我的要求,請告訴我。

謝謝 !

根據文檔 ,似乎無法內聯。 但是,從相同的密鑰生成器配置特定的bean,但是將不同的屬性值映射到不同的bean名稱,這是很簡單的。 然后在@Cacheable批注中引用確切的一個。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM