主要注解
- @EnableAsync 启用异步
- @Async 异步注解
ApplicationEventPublisher发布事件
在Controller中注入ApplicationEventPublisher
用来发布事件
/**
* 注入ApplicationEventPublisher用来发布事件
*/
@Resource
private ApplicationEventPublisher publisher;
使用publisher.publishEvent();
发布事件。SaveJSDataEvent
是我们自定义的事件。
事件Event
创建事件,需要继承ApplicationEvent
这个抽象类。