~~ Spring Boot ~~
1. Introduction
1.1 Spring Boot-Intorduction
1.2 Spring Boot-Architecture
1.2 Spring Boot-Quick Start
2. Project Creation
2.1 Spring Initializer
2.2 Spring Boot CLI
2.3 STS IDE
2.4 Eclipse IDE
2.5 First Program
2.6 Spring Boot-Code Structure
3. Spring Boot – Beans & DI
4. Spring Boot – Runners
5. Spring Boot – Properties File
6. Spring Boot – Looging
7. Spring Boot – Rest WebServices
8. Spring Boot – Exception Handling
9. Spring Boot – Interceptor
10. Spring Boot – Servlet Filter
11. Spring Boot – Rest Template
12. Spring Boot – File HANDLING
13. Spring Boot – Thymeleaf
14. Spring Boot – Internationalization
15. Spring Boot – Scheduling
16. Spring Boot – Actuator
17. Spring Boot – Email Handling
18. Spring Boot – Database Handling
19. Spring Boot – Caching
Spring Boot | Scheduler :
In Spring boot, we have Scheduler which help us to execute some job or task for specific time period. It provides us below 2 important annotations.- @EnableScheduling
- @Scheduled
@EnableScheduleing :
This annotation will enable the scheduler in our project. It will tell to Spring, there are some scheduling job, so that it will load all these configuration and will take care. We need to add this annotation in main Spring Boot application class. Below is small example how to enable it.package com.study4online;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.scheduling.annotation.EnableScheduling; @EnableScheduling @SpringBootApplication public class SchedulingApplication { public static void main(String[] args) { SpringApplication.run(SchedulingApplication.class, args); } }
@Scheduled :
This annotation is used to trigger the Scheduler, we have to configure time frame for job Scheduler. To configure time frame we need to pass any below parameter to @Scheduled annotation. Only condition is the method where we are using this annotation it should be without argument. we will see one by one.- fixedDelay
- initialDelay
- fixedRate
- cron
package com.study4online.scheduler;import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @Component public class MyScheduler { Logger logger = LoggerFactory.getLogger(MyScheduler.class); @Scheduled(fixedDelay = 10000) public void run() { logger.info(“Current Time is : ” + new java.util.Date()); } } Seed below console output of above code, we can see in every 10 sec this job is executing.

2. initialDelay & fixedRate :
fixedRate Scheduler is used to execute job at the specific time. It will not wait to complete the previous job, we can say it’s opposite to fixedJob. Here also we need to specify value in miliseconds. Below is an example.
package com.study4online.scheduler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @Component public class MyScheduler { Logger logger = LoggerFactory.getLogger(MyScheduler.class); @Scheduled(initialDelay = 1000, fixedRate = 10000) public void run() { logger.info("Current Time is :" + new java.util.Date()); } }

4. crone :