springBoot中的异步和定时任务

具体的操做步骤就不写啦java

AsyncService.javaapp

Serviceasync

public class AsyncService {测试

[@Async](https://my.oschina.net/553709938)

public void hello(){this

try {
  
      Thread.sleep(10000);
	  
  }catch (InterruptedException e){
  
      e.printStackTrace();
	  
  }
  System.out.println("数据处理中");

} } 测试 @RestController.net

public class AsyController {code

@Autowiredblog

AsyncService asyncService;

@GetMapping("/hello")get

public String hello(){

asyncService.hello();

return  "success";

} }io

@Service

public class scheduleService {

//,表枚举
//-表区间
//* 表任意
//? 表冲突匹配
// /41 表步长

@Scheduled(cron = "0,1,2,3,5,6 * * * * *")

public void hello(){

System.out.println("hello this is cron schedule");

} }

相关文章
相关标签/搜索