@Scheduled(fixedDelay=10000)
@PostConstruct
public void someMethod(){
//my refresh cache code here
}
If I use both @PostConstruct and @Scheduled on a bean method what will be the consequences. Will this method will be executed twice? one after the other of may be at same time ?
The consequence will be that as soon as the class containing this method is created, the @PostConstruct will run. And the @Scheduled will trigger this method after 10_000ms, but only if @EnabledScheduling is added to the context.
The @Scheduled annotation can do both hence they can be merged like that