FileNotFoundExeception引发的问题
出现的报错方式
java.io.FileNotFoundException: class path resource [D:/workspaces-test/ihrm_parent/ihrm_system/src/main/resources/test.xlsx] cannot be resolved to URL because it does not exist
代码
Resource resource = new ClassPathResource("D:\\workspaces-test\\ihrm_parent\\ihrm_system\\src\\main\\resources\\test.xlsx");
FileInputStream fis = new FileInputStream(resource.getFile());
出现了问题
路径一直找不到
写法错误
//2.加载模板:模板文件
Resource resource = new ClassPathResource("excel-template/hr-demo.xlsx");
FileInputStream fis = new FileInputStream(resource.getFile());
这段代码只会查找在resources下的文件,并不会去找真实文件的路径