方式一、文件输入流
Properties properties = new Properties();
//properties识别位置在工程下
FileInputStream inputStream = new FileInputStream("resources/jdbc.properties");
properties.load(inputStream);
String user = properties.getProperty("key");
方式二、类加载器
Properties properties = new Properties();
ClassLoader classLoader = ClassLoaderTest.class.getClassLoader();
//properties识别位置在src下
InputStream inputStream = classLoader.getResourceAsStream("jdbc.properties");
properties.load(inputStream);
String user = properties.getProperty("key");
若有其他方式可留言告知^ _ ^