I am trying to use Quartz 2.2.1 with spring boot. Im trying to declare a scheduled task that is supposed to write some datas into a file. My Job is defined like below :
Spring Boot manages it for you. Remove the quartz dependency and just create a Service for having scheduled executions:
@Service
public class JobScheduler{
@Autowired
JobController controller;
//Executes each 5000 ms
@Scheduled(fixedRate=5000)
public void performJob() {
controller.doPrintData();
}
}
And enable the task scheduling for your application:
@SpringBootApplication
@EnableScheduling
public class Application {
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class);
}
}
See also: