1.一般配置文件需要放在src目录下
2.步骤
//1.创建Properties对象
Properties pro = new Properties();
//2.读取配置文件,使用ClassLoader加载properties配置文件生成对应的输入流
InputStream is = JedisPoolUtils.class.getClassLoader().getResourceAsStream("jedis.properties");
//3.调用load方法加载属性文件的输入流
try {
pro.load(is);
} catch (IOException e) {
e.printStackTrace();
}
//4.调用getProperties()获取属性
pro.getProperties("user");