适配兼容本地调试和服务器目录
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.lakala.moss.util;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -143,7 +145,16 @@ public class PropertiesUtil {
|
||||
* 静态内部类,单例模式,保证只有一个实例变量
|
||||
*/
|
||||
private static class PropertiesUtilHolder {
|
||||
private static PropertiesUtil instance = new PropertiesUtil(propertiesParentPath, fileEncode);
|
||||
private static PropertiesUtil instance;
|
||||
|
||||
static {
|
||||
String parentPath = propertiesParentPath;
|
||||
if (!Files.exists(Paths.get(parentPath))) {
|
||||
parentPath = PropertiesUtil.class.getClassLoader()
|
||||
.getResource(DEFAULT_PROPERTIES_NAME).getPath().replace(DEFAULT_PROPERTIES_NAME, "");
|
||||
}
|
||||
instance = new PropertiesUtil(parentPath, fileEncode);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 加载配置文件,需要进行加锁
|
||||
|
||||
Reference in New Issue
Block a user