From 56c19f2f5bf8f3e0930e83735568935c0904831d Mon Sep 17 00:00:00 2001 From: ZhengJie <201507802@qq.com> Date: Tue, 9 Jun 2020 20:41:02 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD](v2.5):?= =?UTF-8?q?=20=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/me/zhengjie/utils/StringUtils.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/StringUtils.java b/eladmin-common/src/main/java/me/zhengjie/utils/StringUtils.java index 8daab9f5..5df295c6 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/StringUtils.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/StringUtils.java @@ -27,11 +27,9 @@ import org.lionsoul.ip2region.DbSearcher; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.io.ClassPathResource; - import javax.servlet.http.HttpServletRequest; import java.io.File; import java.io.FileNotFoundException; - import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Calendar; @@ -42,6 +40,7 @@ import java.util.Date; * 字符串工具类, 继承org.apache.commons.lang3.StringUtils类 */ public class StringUtils extends org.apache.commons.lang3.StringUtils { + private static final Logger log = LoggerFactory.getLogger(StringUtils.class); private static boolean ipLocal = false; private static DbSearcher searcher = null; @@ -50,20 +49,16 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils { SpringContextHolder.addCallBacks(() -> { StringUtils.ipLocal = SpringContextHolder.getProperties("ip.local-parsing", false, Boolean.class); if (ipLocal) { - /** + /* * 此文件为独享 ,不必关闭 */ String path = "ip2region/ip2region.db"; String name = "ip2region.db"; - DbConfig config = null; + DbConfig config; try { config = new DbConfig(); File file = FileUtil.inputStreamToFile(new ClassPathResource(path).getInputStream(), name); searcher = new DbSearcher(config, file.getPath()); - } catch (DbMakerConfigException | FileNotFoundException e) { - log.error(e.getMessage(), e); - } catch (NoSuchMethodException e) { - log.error(e.getMessage(), e); } catch (Exception e) { log.error(e.getMessage(), e); }