1、创建项目:只需要选择web模块即可测试
2、异步任务(使用多线程)
1、@EnableAsync
//开启异步功能 @EnableAsync @SpringBootApplication public class Springboot13Application { public static void main(String[] args) { SpringApplication.run(Springboot13Application.class, args); } }
2、@Async
@Service public class TestService { //表示这是一个异步方法 @Async public void test(){ try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("处理中"); } }
3、定时任务
原文:https://www.cnblogs.com/yanxiaoge/p/11386069.html