//Spring Resource API //m1 //Resource resource = new ClassPathResource("classpath:xx.properties"); //m2 //@Autowired //ResourceLoader resourceLoader; //Resource resource = resourceLoader.getResource("classpath:resource.properties"); //多个文件 ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver(); try { Resource[] resources = resourcePatternResolver.getResources("classpath:config/xx*.xml"); } catch (IOException e) { e.printStackTrace(); } InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("excleTemplate/test.xlsx");
//this.getClass().getResourceAsStream("/") = this.getClass().getClassLoader().getResourceAsStream("") InputStream inputStream = this.getClass().getResourceAsStream("/excleTemplate/test.xlsx"); InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("excleTemplate/test/xlsx");