这篇文章主要介绍了Springboot几种任务的整合方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
一 异步任务
启动类
@MapperScan("com.topcheer.*.*.dao")
@SpringBootApplication
@EnableCaching
@EnableRabbit
@EnableAsync
public class Oss6Application {
public static void main(String[] args) {
SpringApplication.run(Oss6Application.class, args);
}
}
Controller层
/**
* @author WGR
* @create 2019/10/12 -- 21:53
*/
@RestController
public class AsynController {
@Autowired
AsynService asyncService;
@GetMapping("/hello")
public String hello(){
asyncService.hello();
return "success";
}
}
Service层
/**
* @author WGR
* @create 2019/10/12 -- 21:52
*/
@Service
public class AsynService {
//告诉Spring这是一个异步方法
@Async
public