package com.jnwat.modules.basics.util;
import java.util.Properties;
import org.springframework.core.io.support.PropertiesLoaderUtils;
/**
* @ClassName: ObtainUserUtil
* @Description: 获取配置文件属性类
* @author dongzy
* @date 2019年12月5日
* @version V1.0
*/
public class PropertiesGetUtil {
/**
* 获取配置文件属性
* @param fileName 配置文件名
* @param protertyKey 属性键
* @return 属性值
* @throws Exception
*/
public static String GetPropertyValue(String fileName,String protertyKey) throws Exception {
// 属性值
String value = "";
try {
// 获取属性文件内容
Properties properties=PropertiesLoaderUtils.loadAllProperties(fileName);
// 根据键获取值
value = properties.getProperty(protertyKey);
} catch (Exception e){
throw e;
}
// 返回属性值
return value;
}
}
///使用
String appid = PropertiesGetUtil.GetPropertyValue("config.properties", "appid");