From e6014dd0e904a7bd7049116069bdb48109c42860 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期日, 27 二月 2022 22:09:53 +0800
Subject: [PATCH] fix 恢复误删 @Async 注解线程池配置类
---
ruoyi-framework/src/main/java/com/ruoyi/framework/config/AsyncConfig.java | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/AsyncConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/AsyncConfig.java
new file mode 100644
index 0000000..47898e3
--- /dev/null
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/AsyncConfig.java
@@ -0,0 +1,54 @@
+package com.ruoyi.framework.config;
+
+import cn.hutool.core.util.ArrayUtil;
+import com.ruoyi.common.exception.ServiceException;
+import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.AsyncConfigurerSupport;
+import org.springframework.scheduling.annotation.EnableAsync;
+
+import java.util.Arrays;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ScheduledExecutorService;
+
+/**
+ * 寮傛閰嶇疆
+ *
+ * @author Lion Li
+ */
+@EnableAsync
+@Configuration
+public class AsyncConfig extends AsyncConfigurerSupport {
+
+ @Autowired
+ @Qualifier("scheduledExecutorService")
+ private ScheduledExecutorService scheduledExecutorService;
+
+ /**
+ * 鑷畾涔� @Async 娉ㄨВ浣跨敤绯荤粺绾跨▼姹�
+ */
+ @Override
+ public Executor getAsyncExecutor() {
+ return scheduledExecutorService;
+ }
+
+ /**
+ * 寮傛鎵ц寮傚父澶勭悊
+ */
+ @Override
+ public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
+ return (throwable, method, objects) -> {
+ throwable.printStackTrace();
+ StringBuilder sb = new StringBuilder();
+ sb.append("Exception message - ").append(throwable.getMessage())
+ .append(", Method name - ").append(method.getName());
+ if (ArrayUtil.isNotEmpty(objects)) {
+ sb.append(", Parameter value - ").append(Arrays.toString(objects));
+ }
+ throw new ServiceException(sb.toString());
+ };
+ }
+
+}
--
Gitblit v1.9.3