package com.util;
import java.io.IOException;
import java.util.Properties;
import org.springframework.core.io.support.PropertiesLoaderUtils;
读取配置文件工具类
/**
*读取propertes文件参数
*/
public class GetPropertiesParmsUtil {
public static String getSysValue(String key){
Properties properties = null;
try {
properties = PropertiesLoaderUtils.loadAllProperties("sys.properties");
} catch (IOException e) {
e.printStackTrace();
}
return properties.getProperty(key);
}
}
方法内的具体调用
parmsMap.put("custid", GetPropertiesParmsUtil.getSysValue("custid"));
要读取的配置文件sys.properties
custid=6666