From 080237cabfbc9eac694e20b6d0b1a8f05c7ffbfe Mon Sep 17 00:00:00 2001 From: zhanliquan Date: Wed, 20 Nov 2019 16:54:22 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8DWar=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8shutdown,ehcache=E5=86=85?= =?UTF-8?q?=E5=AD=98=E6=B3=84=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanliquan --- .../main/java/com/ruoyi/framework/manager/ShutdownManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java index 5c5905fda..afdf44b04 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java @@ -1,6 +1,7 @@ package com.ruoyi.framework.manager; import com.ruoyi.framework.shiro.web.session.SpringSessionValidationScheduler; +import net.sf.ehcache.CacheManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -25,6 +26,7 @@ public class ShutdownManager { shutdownSpringSessionValidationScheduler(); shutdownAsyncManager(); + CacheManager.getCacheManager("ruoyi").shutdown(); } /** From 87b8d032caa068104bb329eb84a37e6d9c265d88 Mon Sep 17 00:00:00 2001 From: zhanliquan Date: Wed, 20 Nov 2019 18:07:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8DWar=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8shutdown,ehcache=E5=86=85?= =?UTF-8?q?=E5=AD=98=E6=B3=84=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanliquan --- .../framework/manager/ShutdownManager.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java index afdf44b04..78a4af372 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java @@ -2,6 +2,7 @@ package com.ruoyi.framework.manager; import com.ruoyi.framework.shiro.web.session.SpringSessionValidationScheduler; import net.sf.ehcache.CacheManager; +import org.apache.shiro.cache.ehcache.EhCacheManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -21,12 +22,15 @@ public class ShutdownManager @Autowired(required = false) private SpringSessionValidationScheduler springSessionValidationScheduler; + @Autowired(required = false) + private EhCacheManager ehCacheManager; + @PreDestroy public void destroy() { shutdownSpringSessionValidationScheduler(); shutdownAsyncManager(); - CacheManager.getCacheManager("ruoyi").shutdown(); + shutdownEhCacheManager(); } /** @@ -63,4 +67,21 @@ public class ShutdownManager logger.error(e.getMessage(), e); } } + + private void shutdownEhCacheManager() + { + try + { + logger.info("====关闭缓存===="); + if (ehCacheManager != null) + { + CacheManager cacheManager = ehCacheManager.getCacheManager(); + cacheManager.shutdown(); + } + } + catch (Exception e) + { + logger.error(e.getMessage(), e); + } + } }