{"id":712,"date":"2019-11-24T21:09:27","date_gmt":"2019-11-24T13:09:27","guid":{"rendered":"http:\/\/prayerlaputa.com\/?p=712"},"modified":"2019-11-24T21:15:19","modified_gmt":"2019-11-24T13:15:19","slug":"712","status":"publish","type":"post","link":"http:\/\/prayerlaputa.com\/?p=712","title":{"rendered":"Spring Boot \u4e0a\u4f20\u6587\u4ef6\u62a5\u9519 The temporary upload location [xxx] is not valid"},"content":{"rendered":"<h1>\u95ee\u9898<\/h1>\n<div class=\"mume markdown-preview \">\n<p>\u5bfc\u5165excel\u6587\u4ef6\u65f6\uff0c\u5076\u53d1bug:<\/p>\n<pre class=\"language-\" data-role=\"codeBlock\" data-info=\"\"><code>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\r\n\tat org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:112)\r\n\tat org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.&lt;init&gt;(StandardMultipartHttpServletRequest.java:86)\r\n\tat org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:79)\r\n\tat org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1104)\r\n\tat org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:936)\r\n\tat org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)\r\n\tat org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)\r\n\tat org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)\r\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:661)\r\n\tat org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)\r\n<\/code><\/pre>\n<h2 id=\"%E5%8E%9F%E5%9B%A0\" class=\"mume-header\">\u539f\u56e0<\/h2>\n<p>Spring boot\u9879\u76ee\u5728\u5bfc\u5165\u6587\u4ef6\u65f6\uff0c\u6ca1\u6709\u627e\u5230\u6307\u5b9a\u6587\u4ef6\u5939\u3002<br \/>\n\u5b50\u6240\u4ee5\u662f\u5076\u53d1\u7684\u95ee\u9898\uff0c\u662f\u56e0\u4e3aspring boot\u9879\u76ee\u672c\u8eab\u5728\u542f\u52a8\u540e\u4f1a\u81ea\u52a8\u5728Temp\u6587\u4ef6\u5939\u4e2d\u521b\u5efa\u82e5\u5e72\u4e34\u65f6\u6587\u4ef6\u5939\uff0c\u800c\u64cd\u4f5c\u7cfb\u7edf\u53ef\u80fd\u4f1a\u5b9a\u671f\u5220\u9664\u8fd9\u4e9b\u4e34\u65f6\u6587\u4ef6\u5939\u3002linux\u4e5f\u6709\u7c7b\u4f3c\u64cd\u4f5c\u7cfb\u7edf\u81ea\u52a8\u6e05\u7a7a\u4e34\u65f6\u6587\u4ef6\u5939\u7684\u64cd\u4f5c\uff0c\u53c2\u89c1\u8fd9\u7bc7\u6587\u7ae0<a href=\"https:\/\/blog.51cto.com\/kusorz\/2051877\">CentOS7\u7684\/tmp\u76ee\u5f55\u81ea\u52a8\u6e05\u7406\u89c4\u5219<\/a>\u3002<\/p>\n<p>&nbsp;<br \/>\n<!--more--><\/p>\n<p>\u6e90\u7801\u5c42\u9762\u7684\u5206\u6790\u53c2\u89c1<a href=\"https:\/\/www.cnblogs.com\/yihuihui\/p\/10372887.html\">SpringBoot\u6587\u4ef6\u4e0a\u4f20\u5f02\u5e38\u4e4b\u63d0\u793aThe temporary upload location xxx is not valid<\/a><\/p>\n<h2 id=\"%E8%A7%A3%E5%86%B3\" class=\"mume-header\">\u89e3\u51b3<\/h2>\n<p>\u624b\u5de5\u6539\u53d8\u4e34\u65f6\u6587\u4ef6\u7684\u5b58\u50a8\u8def\u5f84\uff0c\u5e76\u4e14\u5982\u679c\u8be5\u8def\u5f84\u4e0b\u7684\u6587\u4ef6\u5939\u6ca1\u6709\u521b\u5efa\uff0c\u5219\u7528\u7a0b\u5e8f\u6765\u521b\u5efa\uff0c\u4fdd\u8bc1\u8def\u5f84\u6709\u6548\u3002<\/p>\n<pre class=\"language-\" data-role=\"codeBlock\" data-info=\"\"><code>@Configuration\r\npublic class MultipartConfig {\r\n\r\n    \/**\r\n     * \u6587\u4ef6\u4e0a\u4f20\u4e34\u65f6\u8def\u5f84\r\n     *\/\r\n    @Bean\r\n    MultipartConfigElement multipartConfigElement() {\r\n        MultipartConfigFactory factory = new MultipartConfigFactory();\r\n        String location = System.getProperty(\"user.dir\") + \"\/data\/tmp\";\r\n        File tmpFile = new File(location);\r\n        if (!tmpFile.exists()) {\r\n            tmpFile.mkdirs();\r\n        }\r\n        factory.setLocation(location);\r\n        return factory.createMultipartConfig();\r\n    }\r\n}\r\n<\/code><\/pre>\n<h2 id=\"%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99\" class=\"mume-header\">\u53c2\u8003\u8d44\u6599<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.cnblogs.com\/yihuihui\/p\/10372887.html\">SpringBoot\u6587\u4ef6\u4e0a\u4f20\u5f02\u5e38\u4e4b\u63d0\u793aThe temporary upload location xxx is not valid<\/a><\/li>\n<li><a href=\"https:\/\/blog.51cto.com\/kusorz\/2051877\">CentOS7\u7684\/tmp\u76ee\u5f55\u81ea\u52a8\u6e05\u7406\u89c4\u5219<\/a><\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/llibin1024530411\/article\/details\/79474953\">SpringBoot\u9879\u76ee\u7684The temporary upload location ***is not valid \u95ee\u9898<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u9898 \u5bfc\u5165excel\u6587\u4ef6\u65f6\uff0c\u5076\u53d1bug: org.springframework.web.multipart. <a href='http:\/\/prayerlaputa.com\/?p=712' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[91,75],"tags":[92,76],"_links":{"self":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts\/712"}],"collection":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=712"}],"version-history":[{"count":4,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts\/712\/revisions"}],"predecessor-version":[{"id":717,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts\/712\/revisions\/717"}],"wp:attachment":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=712"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}