我是靠谱客的博主 玩命爆米花,这篇文章主要介绍class path resource [xx] cannot be resolved to absolute file path because it does not reside,现在分享给大家,希望可以做个参考。
String fileName = "lenovo_data";
方式一:
ClassPathResource resource = new ClassPathResource("fileName");
File file = resource.getFile();
方式二:
String path = ResourceUtils.getURL("classpath:").toString();
File file = new File(path, fileName);
以上两种方式获取spring boot 项目资源文件下文件时,在 eclipse 环境中测试是可以获取到的,但是当打成jar包测试时,会抛出class path resource [xx] cannot be resolved to absolute file path because it does not reside 异常错误。
最后
以上就是玩命爆米花最近收集整理的关于class path resource [xx] cannot be resolved to absolute file path because it does not reside的全部内容,更多相关class内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复