Spring boot 使用异步@Async

来源:互联网 发布:js身份证号正则表达式 编辑:程序博客网 时间:2024/06/06 09:43

1:启动类添加 @EnableAsync 注解
2:新建Async类

package com.myhitron.jlw.mall.async;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.scheduling.annotation.Async;import org.springframework.stereotype.Component;import com.myhitron.jlw.core.util.PdfboxUtil;@Componentpublic class JlwAsync {    private Logger logger = LoggerFactory.getLogger(JlwAsync.class);    @Async    public void writePicAsync(String pdfFileName, String picPath, Integer dpi, Integer maxPicCount) {        PdfboxUtil pdfboxUtil = PdfboxUtil.getInstace();        pdfboxUtil.writePic(pdfFileName, picPath, dpi, maxPicCount);    }}

3:直接调用该方法

阅读全文
0 0
原创粉丝点击