Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why spring @schedule do not work with @Lazy

    @Lazy
    @Component
    public class ScheduleTest {
       @Scheduled(fixedRate = 1000)
       public  void  doSomething(){
          System.out.println("do something"+ new Date());
       }
   }

when i set the lazy(value=false),it works.

like image 730
islandev Avatar asked Jan 31 '26 21:01

islandev


1 Answers

Based on the following Jira ticket, it works from Spring 4.3 RC2 version.

Logically it didn't work, because @Lazy means that don't instantiate this bean, unless it is injected somewhere, but @Scheduled proxy was created when the bean was instantiated.

like image 169
helospark Avatar answered Feb 03 '26 09:02

helospark