报错信息:
"localizedMessage": "The temporary upload location [C:\\Users\\YY\\AppData\\Local\\Temp\\tomcat.1793760262133383655.8081\\work\\Tomcat\\localhost\\ROOT] is not valid","message": "The temporary upload location [C:\\Users\\YY\\AppData\\Local\\Temp\\tomcat.1793760262133383655.8081\\work\\Tomcat\\localhost\\ROOT] is not valid","suppressed": []
import org.springframework.boot.web.servlet.MultipartConfigFactory;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import javax.servlet.MultipartConfigElement;import java.io.File;/** * 配置文件上传临时路径,解决上传报错的问题 * localizedMessage: * "The temporary upload location * [C:\Users\YY\AppData\Local\Temp\tomcat.3305898259059649641.8083\work\Tomcat\localhost\ROOT] * is not valid" */@Configurationpublic class MultipartConfig { /** * 文件上传临时路径 */ @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(); }}