2022
03-01
03-01
springboot打成jar后获取classpath下文件失败的解决方案
springboot打成jar后获取classpath下文件代码如下:ClassPathResourceresource=newClassPathResource("app.keystore");Filefile=resource.getFile();FileUtils.readLines(file).forEach(System.out::println);解决方式如下:1.SpringframeworkStringdata="";ClassPathResourcecpr=newClassPathResource("static/file.txt");try{byte[]bdata=FileCopyUtils.copyToByteArray(cpr.getInputStream());data...
继续阅读 >