From bf6940ae9291276a25613a2d67a3d36d0ec3024d Mon Sep 17 00:00:00 2001 From: thinkgem Date: Sun, 2 Feb 2020 12:46:42 +0800 Subject: [PATCH] =?UTF-8?q?PropertiesUtils=E6=8F=90=E9=86=92=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeesite/common/io/PropertiesUtils.java | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/common/src/main/java/com/jeesite/common/io/PropertiesUtils.java b/common/src/main/java/com/jeesite/common/io/PropertiesUtils.java index ece83262..4530e3cc 100644 --- a/common/src/main/java/com/jeesite/common/io/PropertiesUtils.java +++ b/common/src/main/java/com/jeesite/common/io/PropertiesUtils.java @@ -105,18 +105,19 @@ public class PropertiesUtils { */ public PropertiesUtils(String... configFiles) { for (String location : configFiles) { - try { - Resource resource = ResourceUtils.getResource(location); - if (resource.exists()){ - if (location.endsWith(".properties")){ - try (InputStreamReader is = new InputStreamReader(resource.getInputStream(), "UTF-8")){ - properties.load(is); - configSet.add(location); - } catch (IOException ex) { - logger.error("Load " + location + " failure. ", ex); - } + Resource resource = ResourceUtils.getResource(location); + if (resource.exists()){ + if (location.endsWith(".properties")){ + try (InputStreamReader is = new InputStreamReader(resource.getInputStream(), "UTF-8")){ + properties.load(is); + configSet.add(location); + } catch (IOException e) { + System.err.println("Load " + location + " failure."); + e.printStackTrace(); } - else if (location.endsWith(".yml")){ + } + else if (location.endsWith(".yml")){ + try { YamlPropertiesFactoryBean bean = new YamlPropertiesFactoryBean(); bean.setResources(resource); for (Map.Entry entry : bean.getObject().entrySet()){ @@ -124,10 +125,11 @@ public class PropertiesUtils { ObjectUtils.toString(entry.getValue())); } configSet.add(location); - } - } - } catch (Exception e) { - logger.error("Load " + location + " failure. ", e); + } catch (Exception e) { + System.err.println("Load " + location + " failure."); + e.printStackTrace(); + } + } } } properties.put("configFiles", StringUtils.join(configFiles, ","));