private static final String CONSTANT = (p.getProperty("MILLISECONDS_OF_12_HOURS"));
@Scheduled(fixedRateString = CONSTANT)
public void clearCache() throws IOException {
if(!rrcodeService.cachedAccessGroups.isEmpty()) {
for (Entry<String, CachedAccessGroups> entry : rrcodeService.cachedAccessGroups.entrySet()) {
String key = entry.getKey();
CachedAccessGroups accessGroups = rrcodeService.cachedAccessGroups.get(key);
if(now.getTime() - accessGroups.getCachedDate().getTime()> Integer.parseInt(p.getProperty("EVICT_CACHE"))) {
rrcodeService.cachedAccessGroups.remove(key);
}
}
}
}
The value for MILLISECONDS_OF_12_HOURS is being set in the external properties file. And I am trying to set that value to FixedRateString. But its throwing error saying "The value for annotation attribute Scheduled.fixedRateString must be a constant expression" Any help would be appreciated.. Thanks!