SpringBoot中资源可以默认被访问的路径:https://www.jianshu.com/p/6e7611b45216
如,想指定本地磁盘D:/upload/为图片文件存放路径:
spring:
resources:
static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:${file.storage.local.baseDir}
server:
port: 8080
file:
storage:
local:
baseDir: D:/upload/
保证D:/upload/目录存在,启动项目并访问文件,结果如下: