spring-boot項目,生產環境運行一段時間後,上傳圖片報錯,以下:java
threw exception [Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [/tmp/tomcat.2982178524163133296.8080/work/Tomcat/localhost/ssc] is not valid] with root cause] |
java.io.IOException: The temporary upload location [/tmp/tomcat.2982178524163133296.8080/work/Tomcat/localhost/ssc] is not validweb
解決方案:添加指定目錄spring
@Configuration public class MultipartConfig { /** * 文件上傳臨時路徑 */ @Bean MultipartConfigElement multipartConfigElement() { MultipartConfigFactory factory = new MultipartConfigFactory(); factory.setLocation("/data/dubbo/cache"); return factory.createMultipartConfig(); } }