Properties prop = new Properties();
//读取classPath中的properties文件
try {
prop.load(this.getClass().getClassLoader().getResourceAsStream("application.properties"));
} catch (IOException e) {
e.printStackTrace();
}
//根据键取出值
String host = prop.getProperty("host");
int port = Integer.parseInt(prop.getProperty("port"));
spring读配置文件
最新推荐文章于 2023-05-25 20:13:29 发布