@Autowired
@Value("classpath:sql.properties")
private Resource resource;
public Map<String,String> readPropertiesFile() throws IOException{
Map<String,String> map = new HashMap<String,String>();
BufferedReader br = new BufferedReader(new FileReader(this.resource.getFile()));
String s;
while ((s=br.readLine())!=null){
String[] str = s.split("=");
map.put(str[0], str[1]);
}
return map;
}
spring 读取属性文件
最新推荐文章于 2024-07-11 21:09:38 发布