简体   繁体   中英

Spring: How to use annotation as a parameter to another annotation?

I am trying to do something like this

@Cacheevict(@Value("#{properties.cacheName}")

Syntax wise , this is wrong . Any other way to implement such functionality?

For those annotation attributes that support SpEL it is documented in the API documentation and in such cases you can simply add the SpEL directly instead of wrapping it in another @Value annotation.

Unfortunatly the value attribute of the @CacheEvict annotation doesn't support SpEL expressions and as such can only directly contain the names of the caches to evict.

在您的方案中,我认为您应该为高速缓存名称到真实高速缓存的这种非静态映射实现CacheManager接口。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM