From a07e5d783374f379cf51e74be5cd2b54fa6147aa Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期一, 22 一月 2024 13:02:43 +0800
Subject: [PATCH] update 优化 解除注释 使用spring包装虚拟线程池无须担心idea警告问题

---
 ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/config/ValidatorConfig.java |   25 +++++++++++++------------
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/config/ValidatorConfig.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/config/ValidatorConfig.java
index 00825c2..45c5bd1 100644
--- a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/config/ValidatorConfig.java
+++ b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/config/ValidatorConfig.java
@@ -22,18 +22,19 @@
      */
     @Bean
     public Validator validator(MessageSource messageSource) {
-        LocalValidatorFactoryBean factoryBean = new LocalValidatorFactoryBean();
-        // 鍥介檯鍖�
-        factoryBean.setValidationMessageSource(messageSource);
-        // 璁剧疆浣跨敤 HibernateValidator 鏍¢獙鍣�
-        factoryBean.setProviderClass(HibernateValidator.class);
-        Properties properties = new Properties();
-        // 璁剧疆 蹇�熷紓甯歌繑鍥�
-        properties.setProperty("hibernate.validator.fail_fast", "true");
-        factoryBean.setValidationProperties(properties);
-        // 鍔犺浇閰嶇疆
-        factoryBean.afterPropertiesSet();
-        return factoryBean.getValidator();
+        try (LocalValidatorFactoryBean factoryBean = new LocalValidatorFactoryBean()) {
+            // 鍥介檯鍖�
+            factoryBean.setValidationMessageSource(messageSource);
+            // 璁剧疆浣跨敤 HibernateValidator 鏍¢獙鍣�
+            factoryBean.setProviderClass(HibernateValidator.class);
+            Properties properties = new Properties();
+            // 璁剧疆 蹇�熷紓甯歌繑鍥�
+            properties.setProperty("hibernate.validator.fail_fast", "true");
+            factoryBean.setValidationProperties(properties);
+            // 鍔犺浇閰嶇疆
+            factoryBean.afterPropertiesSet();
+            return factoryBean.getValidator();
+        }
     }
 
 }

--
Gitblit v1.9.3