properties文件读取

 
方式一:ResourceBundle(常用)
ResourceBundle bundle = ResourceBundle.getBundle("文件名")
bundle.getString("字段名")
方式二:ClassLoad
InputStream in = 类名.class.getClassLoader().getResourceAsStream("XXX.properties");
Properties props = new Properties();
props .load(in)
props.getProperty(key)
方式三:spring 加载配置文件方式
posted @ 2022-07-26 10:21  王广福  阅读(26)  评论(0)    收藏  举报