SprintBoot

Brief

  1. Out of time: from the time the Maven repository to see 2016.7.28
  2. 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
  3. Thought: convention over configuration (convention over configuration)
  4. Framework features: a large number of popular third integrated library configuration (Jackson, JDBC, Mongo, Redis, Mail, etc.)

getting Started

Create a scheduled task

  1. Spring Boot added to main class @EnableSchedulingannotations arranged to enable the timing task;

    @SpringBootApplication
    @EnableScheduling
    public class Application {
     public static void main(String[] args) {
         SpringApplication.run(Application.class, args);
     }
    }
  2. 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()));
        }
    }

Guess you like

Origin www.cnblogs.com/lshare/p/11334423.html