应用场景:
在使用spring boot的时候,有时候静态文件或是上传的图片视频需要放置到其他盘符目录下,这种情况下项目怎么访问其他盘符下的文件呢?
需要先在application.properties
属性文件中配置本地上传文件的路径:
spring.http.multipart.location=D:/crowd-funding/media/
然后将本地上传文件的路径加入到静态资源路径中即可:
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/, classpath:/static/, classpath:/public/, file:${spring.http.multipart.location}
最后访问本地media路径下的文件img.png:
http://localhost:8080/img.png
这种方法可以解决spring boot整合Ueditor时候,将文件放置到其他盘符的问题。
实例:
参考文章:https://blog.csdn.net/u011726984/article/details/78470354