Spring Boot Cache - Cannot Get the value

Here is my application yaml file
exchange-api:
cache-name: exchanges
cache-ttl: 10000 # 10 seconds
exchange-api:
cache-name: exchanges
cache-ttl: 10000 # 10 seconds
Here is the method
@CacheEvict(allEntries = true, cacheNames = "${exchange-api.cache-name}")
@PostConstruct
@Scheduled(fixedRateString = "${exchange-api.cache-ttl}")
public void clearCache() {
logger.info("Caches are cleared");
}
@CacheEvict(allEntries = true, cacheNames = "${exchange-api.cache-name}")
@PostConstruct
@Scheduled(fixedRateString = "${exchange-api.cache-ttl}")
public void clearCache() {
logger.info("Caches are cleared");
}
Here is the error
java.lang.IllegalArgumentException: Cannot find cache named '${exchange-api.cache-name}' for Builder[public void com.example.demo.controller.Controller.clearCache()] caches=[${exchange-api.cache-name}] | key='' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='',true,false
Here is the error
java.lang.IllegalArgumentException: Cannot find cache named '${exchange-api.cache-name}' for Builder[public void com.example.demo.controller.Controller.clearCache()] caches=[${exchange-api.cache-name}] | key='' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='',true,false
How can I fix it as I get the value as ${exchange-api.cache-name} from application.yaml file? I hope you can help me?
1 Reply
JavaBot
JavaBot4mo ago
This post has been reserved for your question.
Hey @direct_x_34! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here. 💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server