springboot 中File获取resources目录下静态资源找不到文件问题FileNotFoundException(No such file or directory)
亲测有效
不要使用用File类,改用Spring的org.springframework.core.io.ClassPathResource类,完美解决
ClassPathResource cpr = new ClassPathResource("static/image/valid.jpg");
InputStream fileInputStream = cpr.getInputStream();
BufferedImage imageTemplate = ImageIO.read(fileInputStream);
即兼容了Windows,linux上也不会有问题
阅读文档:https://blog.csdn.net/qq_36175946/article/details/103805689