博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring boot 注解@Async无效,不起作用
阅读量:3944 次
发布时间:2019-05-24

本文共 192 字,大约阅读时间需要 1 分钟。

解决思路:

1.先查看启动类是否加上 @EnableAsync 注解,如果没有,就加上该注解再重新启动

2.查看异步方法的调用方式是否正确 @Async
3.@Async的调用涉及到动态代理,如果直接将需要异步操作的方法写到业务类中,业务类直接调用,则执行逻辑不会走到代理类,异步就会失效,所以异步方法单独拿出来封装到一个类中,再将这个类注入到业务类中,业务类通过这个类来调用异步方法

在这里插入图片描述

转载地址:http://pkowi.baihongyu.com/

你可能感兴趣的文章
Saving Files
查看>>
Saving Data in SQL Databases
查看>>
Sending the User to Another App
查看>>
Getting a Result from an Activity
查看>>
Allowing Other Apps to Start Your Activity
查看>>
Using the Location Manager
查看>>
Obtaining the Current Location
查看>>
Displaying the Location Address
查看>>
Connecting to the Network
查看>>
Managing Network Usage
查看>>
Parsing XML Data
查看>>
Optimizing Downloads for Efficient Network Access
查看>>
Minimizing the Effect of Regular Updates
查看>>
Redundant Downloads are Redundant
查看>>
Modifying your Download Patterns Based on the Connectivity Type
查看>>
Supporting Different Screen Sizes支持不同的屏幕尺寸
查看>>
Supporting Different Densities 支持各种屏幕密度
查看>>
Implementing Adaptative UI Flows 实施自适应用户界面流程
查看>>
Crossfading Two Views 淡入淡出的两种观点
查看>>
Using ViewPager for Screen Slides 使用屏幕幻灯片ViewPager
查看>>