博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
springboot打成jar包后无法读取resource下资源
阅读量:4228 次
发布时间:2019-05-26

本文共 178 字,大约阅读时间需要 1 分钟。

在开发环境下我们可以用

ResourceUtils.getFile("classpath:pictures/a.png");

的方式读取资源,但是打成jar包后,访问就报错了,jar只能以流的方式读取,如下

ClassPathResource resource = new ClassPathResource(imagePath);

如上方式可以正确读取。

转载地址:http://chjqi.baihongyu.com/

你可能感兴趣的文章
Palm OS Programming Bible
查看>>
XSLT Quickly
查看>>
Inside XSLT
查看>>
Python & XML
查看>>
Java Cryptography
查看>>
J2EE Best Practices: Java Design Patterns, Automation, and Performance
查看>>
Mastering AspectJ: Aspect-Oriented Programming in Java
查看>>
Mastering Jakarta Struts
查看>>
Java and XSLT
查看>>
Learning PHP 5
查看>>
Building Java Enterprise Applications Volume I: Architecture
查看>>
Microsoft SQL Server 2000 Weekend Crash Course
查看>>
Struts: The Complete Reference
查看>>
Complex IT Project Management: 16 Steps to Success
查看>>
Project Risk Management Guidelines : Managing Risk in Large Projects and Complex Procurements
查看>>
SQL for Microsoft Access
查看>>
Visual Basic 2005 Express: Now Playing
查看>>
Jakarta Struts Cookbook
查看>>
AspectJ Cookbook
查看>>
IntelliJ IDEA in Action
查看>>