Java @方法中的异步将抛出org.apache.ibatis.exceptions.PersistenceException

Java @方法中的异步将抛出org.apache.ibatis.exceptions.PersistenceException,java,spring,mybatis,Java,Spring,Mybatis,以下是我的方法: @Async @Override public void managerSmsBlackListExportTxt(SmsBlackImportInput input) { String blackMobile = input.getSmsBlackPhones(); String regex = "\r\n"; String[] blackMobiles = blackMobile.split(regex); Set<String>

以下是我的方法:

@Async
@Override
public void managerSmsBlackListExportTxt(SmsBlackImportInput input) {
    String blackMobile = input.getSmsBlackPhones();
    String regex = "\r\n";
    String[] blackMobiles = blackMobile.split(regex);

    Set<String> blackMobilesSet = new HashSet<>(Arrays.asList(blackMobiles));
    List<SystemPhoneFailedList> failedList = new ArrayList<>();    
    for (String userTel : blackMobilesSet) { 
        if (! this.checkTelephone(userTel.trim())){
            SystemPhoneFailedList systemPhoneFailedList = new SystemPhoneFailedList();
            ...
            failedList.add(systemPhoneFailedList);
            continue;
        }
        ...
    }

    systemPhoneFailedListBizMapper.insertSystemPhoneFailedListBatch(failedList); // the exception is in this line
}


如果我删除
@Async
,此方法将正常,数据将成功插入MySQL。

是否使用
@EnableAsync
启用了对方法的异步调用?是,启用了对我的方法的异步调用,这是我的xml配置。请检查此类中添加的@EnableAsync注释。您是否已将
RequestContextListener
类添加到servlet上下文中?您使用的是XML还是Java配置?可能与的重复您是否使用
@EnableAsync
启用了对方法的异步调用?是的,启用了对我的方法的异步调用,这是我的xml配置。请检查此类中添加的@EnableAsync注释。您是否已将
RequestContextListener
类添加到servlet上下文中?您使用的是XML还是Java配置?可能与
Error updating database.  Cause: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.

Cause: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.