PropertiesUtils提醒信息优化
This commit is contained in:
@@ -105,18 +105,19 @@ public class PropertiesUtils {
|
|||||||
*/
|
*/
|
||||||
public PropertiesUtils(String... configFiles) {
|
public PropertiesUtils(String... configFiles) {
|
||||||
for (String location : configFiles) {
|
for (String location : configFiles) {
|
||||||
try {
|
Resource resource = ResourceUtils.getResource(location);
|
||||||
Resource resource = ResourceUtils.getResource(location);
|
if (resource.exists()){
|
||||||
if (resource.exists()){
|
if (location.endsWith(".properties")){
|
||||||
if (location.endsWith(".properties")){
|
try (InputStreamReader is = new InputStreamReader(resource.getInputStream(), "UTF-8")){
|
||||||
try (InputStreamReader is = new InputStreamReader(resource.getInputStream(), "UTF-8")){
|
properties.load(is);
|
||||||
properties.load(is);
|
configSet.add(location);
|
||||||
configSet.add(location);
|
} catch (IOException e) {
|
||||||
} catch (IOException ex) {
|
System.err.println("Load " + location + " failure.");
|
||||||
logger.error("Load " + location + " failure. ", ex);
|
e.printStackTrace();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (location.endsWith(".yml")){
|
}
|
||||||
|
else if (location.endsWith(".yml")){
|
||||||
|
try {
|
||||||
YamlPropertiesFactoryBean bean = new YamlPropertiesFactoryBean();
|
YamlPropertiesFactoryBean bean = new YamlPropertiesFactoryBean();
|
||||||
bean.setResources(resource);
|
bean.setResources(resource);
|
||||||
for (Map.Entry<Object,Object> entry : bean.getObject().entrySet()){
|
for (Map.Entry<Object,Object> entry : bean.getObject().entrySet()){
|
||||||
@@ -124,10 +125,11 @@ public class PropertiesUtils {
|
|||||||
ObjectUtils.toString(entry.getValue()));
|
ObjectUtils.toString(entry.getValue()));
|
||||||
}
|
}
|
||||||
configSet.add(location);
|
configSet.add(location);
|
||||||
}
|
} catch (Exception e) {
|
||||||
}
|
System.err.println("Load " + location + " failure.");
|
||||||
} catch (Exception e) {
|
e.printStackTrace();
|
||||||
logger.error("Load " + location + " failure. ", e);
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
properties.put("configFiles", StringUtils.join(configFiles, ","));
|
properties.put("configFiles", StringUtils.join(configFiles, ","));
|
||||||
|
|||||||
Reference in New Issue
Block a user