初始化时加载
loadConfProps()
import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.util.Assert;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
public class SysConfig {
/**
* 配置文件属性
*/
private static Properties masterProperties = new Properties();
/**
* 加载resMasterConf的属性配置文件,并且初始化系统参数
*/
public static final void loadCndMasterConfProps() {
try {
Properties cndMasterProperties = PropertiesLoaderUtils
.loadAllProperties("conf/masterProperties.properties");
masterProperties .putAll(masterProperties );
} catch (IOException e) {
throw new RuntimeException(e);
}
}
/**
* 获取属性配置值
*
* @param key
* @return
*/
public static String getPropertiesByKey(String key) {
Assert.notNull(key, "Resource name must not be null");
return cndMasterProperties.getProperty(key);
}
}
</pre><pre name="code" class="java">