org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [/tmp/tomcat.2737591724424319502.8062/work/Tomcat/localhost/ROOT] is not valid
临时文件地址无效
解决办法:
1.重启服务。
2.增加启动参数-Djava.io.tmpdir=自定义目录
3.注入配置:
@Bean
MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
String location = System.getProperty("user.dir") + "/data/tmp";
File tmpFile = new File(location);
if (!tmpFile.exists()) {
tmpFile.mkdirs();
}
factory.setLocation(location);
return factory.createMultipartConfig();
}
来源:CSDN
作者:ZQB765720343
链接:https://blog.csdn.net/ZQB765720343/article/details/104184795