Simple Java Scheduled Timer

 

import java.io.IOException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@SuppressWarnings ( "All")
@EnableScheduling // If you do not add this annotation, the timer will not start, the role of this sentence is similar to Spring's xml namespace <Task: *>
public class ScheduledTasks {

// @Autowired
/ / Private xXXXService xxxxService;


// day two in the morning to perform this function executes
@Scheduled (cron = "00 00 2 * *?")
public void the Test () throws IOException {
System.out.println ( "11111hahaha");
}
}

Guess you like

Origin www.cnblogs.com/foreverstudy/p/11672441.html