@Scheduled 使用问题

来源:互联网 发布:linux默认开启小键盘 编辑:程序博客网 时间:2024/06/05 03:46

使用@Scheduled时,需要启动task
启动方式:
1.使用xml方式,在spring配置文件中添加

<task:annotation-driven>

2.使用spring configuration方式,在配置类即@Configuration下加上@EnableScheduling

@Configuration@EnableScheduling@PropertySource({"classpath:application.properties", "classpath:config.properties"})@EnableTransactionManagement(proxyTargetClass = true)public class AppConfig {}

官方文档:官方文档地址

原创粉丝点击