Spring boot打成jar包后,读取resources中静态文件:
ClassPathResource resource = new ClassPathResource(filename);
resource.getInputStream())
要用字符流形式读取。
Spring boot打成jar包后,读取其它位置的文件
String path = System.getProperty("user.dir");
Resource resource = new ClassPathResource(path+filename);
File file = = new File(path+filename);
读取jar包同一下目录下的文件。