11月 242019
 

问题

导入excel文件时,偶发bug:

org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [C:\Users\AppData\Local\Temp\tomcat.4266029690466887869.8037\work\Tomcat\localhost\ROOT] is not valid
	at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:112)
	at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.<init>(StandardMultipartHttpServletRequest.java:86)
	at org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:79)
	at org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1104)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:936)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)

原因

Spring boot项目在导入文件时,没有找到指定文件夹。
子所以是偶发的问题,是因为spring boot项目本身在启动后会自动在Temp文件夹中创建若干临时文件夹,而操作系统可能会定期删除这些临时文件夹。linux也有类似操作系统自动清空临时文件夹的操作,参见这篇文章CentOS7的/tmp目录自动清理规则

 
Continue reading »

9月 052019
 

问题

spring boot + spring cloud,上传附件时遇到如下错误:

org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (11963927) exceeds the configured maximum (10485760)

错误信息表示上传附件报超出自带tomacat限制大小(默认1M)
Continue reading »