不能直接获取文件资源路径,但是可以通过流的方式读取资源 ClassPathResource resource = new ClassPathResource("static"+File.separator+"test.txt"); try (InputStream in = resource.getInputStream()){ //下载文件 return IOUtils.toString(in, StandardCharsets.UTF_8); } catch (IOException e) { e.printStackTrace(); return e.getMessage(); }
springboot jar resource file
最新推荐文章于 2024-06-02 17:15:32 发布