springBoot 连接打包成jar包运行时,获取图片上传文件、前端页面等文件
问题背景:在使用springboot进行开发时,会将项目打包成jar包,进行运行。
问题1:使用文件上传功能后,怎么获取文件?
问题2:每次更新前端文件,都需要重新运行项目jar包,是否过于麻烦
解决方法
在application.properties/application.yml中进行配置
web.upload-path=d:/myfile/upload
web.front-path=d:/myfile/front
spring.resources.static-locations=file:${web.upload-path},file:${web.front-path}
properties配置方式
web:
upload-path: d:/myfile/upload
front-path: d:/myfile/front</