This is the set up
application.properties
Property.cache = name1,name2,...,nameN
CacheManager.java
[...]
@Scheduler(time_of_schedule)
@CacheEvict(value="#'${property.cache}.split()'")
void dueCache(){
log.info("cache clean");
}
[...]
The issue is that @CacheEvict value throws nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'property.cache'.split(',')' in value "#{'${property.cache'.split(',')}" this is because value is a String[] normally this would work with String attributes.
Is there any way to do it with SpEL?
I tryed with 4 ways:
@CacheEvict(value = "#{'${property.cache}'.split(',')}", allEntries = true)@CacheEvict(value = "#{T(java.util.Arrays).asList(#root.getProperty('property.cache').split(','))}", allEntries = true)@CacheEvict(value = {"cache1","cache2"}, allEntries = true)@CacheEvict(value = "cache1", allEntries = true)
The options 1 and 2 would work if value was a String value() but value is defined as String[] value().
The options 3 and 4 work, but is unresonable to write value = {"cache1","cache2",.....,"cachen"} if there is a way to use properties.