springboot 上传文件时报错
问题描述:
Could not parse multipart servlet request; nested exception is java.lang.IllegalStateException: Unable to process parts as no multi-part configuration has been provided
这个问题该怎么解决
答
application.properties加上如下配置试试
# spring-boot自带的文件上传配置。
# 允许上传
spring.http.multipart.enabled=true
# Threshold after which files will be written to disk. Values can use the suffixed "MB" or "KB" to indicate a Megabyte or Kilobyte size.
spring.http.multipart.file-size-threshold=0
# 上传文件的临时目录
# spring.http.multipart.location=
# 单个文件的大小限制
spring.http.multipart.max-file-size=1MB
# 整个请求的大小限制
spring.http.multipart.max-request-size=10MB
# 不懒加载
spring.http.multipart.resolve-lazily=false