You need to warm up a cache after Spring injects all dependencies. Where should this setup logic commonly go?
Practice this question from Quiz: Spring Core, with options and an explanation.
Question
You need to warm up a cache after Spring injects all dependencies. Where should this setup logic commonly go?
Option A — Correct answer
@PostConstruct method
@PostConstruct is called after dependency injection.
Option B
@PreDestroy method
Option C
equals() method
Option D
main method in every bean
Explanation
@PostConstruct runs after construction and dependency injection.