不需要三方依赖
直接读取等号两边的内容
代码
InputStream isp = this.getClass().getClassLoader().getResourceAsStream("application.properties");
Properties properties = new Properties();
try {
properties.load(isp);
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(properties.getProperty("myName"));
配置文件
url = "jdbc:mysql://localhost:3306/"
usernName = "root"
password = "123"