Brief
- Out of time: from the time the Maven repository to see 2016.7.28
- Objective: To get rid of a lot of XML configuration files and complex dependencies Bean, fast and agile to develop a new generation of applications based on the Spring Framework
- Thought: convention over configuration (convention over configuration)
- Framework features: a large number of popular third integrated library configuration (Jackson, JDBC, Mongo, Redis, Mail, etc.)
getting Started
Create a scheduled task
Spring Boot added to main class
@EnableScheduling
annotations arranged to enable the timing task;@SpringBootApplication @EnableScheduling public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
Use
@Scheduled(fixedRate = 1000)
annotation method requires regular implementation of the class implementation.@Component public class ScheduledTasks implements Runnable{ private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); @Override @Scheduled(fixedRate = 1000) public void run() { System.out.println("Current: " + dateFormat.format(new Date())); } }