我有一个简单的Spring Scheduler示例:
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class AppScheduler {
@Scheduled(fixedRate = 10000)
public void myScheduler() {
System.out.println("Test print");
}
}
比如说从网页上当前可以触发执行吗?
答案 0 :(得分:1)
只需使转储控制器调用myScheduler
方法:
@Controller
public class DumpController {
@Autowired
private AppScheduler scheduler;
@RequestMapping("/ping")
public void ping() {
scheduler.myScheduler();
}
}