获取.properties配置文件属性值
public class TestProperties { /** * * @Title: printAllProperty * @Description: 输出所有配置信息 * @param props * @return void * @throws */ private static void printAllProperty(Properties props) { @SuppressWarnings( "rawtypes" ) Enumeration en = props.propertyNames(); while (en.hasMoreElements()) { String key = (String) en.nextElement(); String value = props.getProperty(key); System.out.println(key + " : " + value); } } /** * 根据key读取value * * @Title: getProperties_1 * @Description: 第一种方式:根据文件名使用spring中的工具类进行解析 * filePath是相对路劲,文件需在classpath目录下 * 比如:config.properties在包com.test.config下, * 路径就是com/test