1. 程式人生 > >SpringBoot專案的The temporary upload location ***is not valid 問題

SpringBoot專案的The temporary upload location ***is not valid 問題

springboot專案,部署到伺服器後,執行一段時間後,處理一些檔案上傳的介面時,後報異常。

Could not parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [/tmp/tomcat.7333297176951596407.9000/work/Tomcat/localhost/ROOT] is not valid。

查閱資料後,發現是centos對'/tmp'下檔案自動清理的原因。

在springboot專案啟動後,系統會在‘/tmp’目錄下自動的建立幾個目錄(我的專案是以下的資料夾):

       1, hsperfdata_root,

        2,tomcat.************.8080,(結尾是專案的端後)

       3,tomcat-docbase.*********.8080。

Multipart(form-data)的方式處理請求時,預設就是在第二個目錄下建立臨時檔案的。

  這篇文章對自動清理檔案有很好的說明http://blog.51cto.com/kusorz/2051877?utm_source=oschina-app。

處理方式:改變臨時檔案的儲存路徑。如下:

@Configuration
public 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(); } }

相關推薦

SpringBoot專案The temporary upload location ***is not valid 問題

springboot專案,部署到伺服器後,執行一段時間後,處理一些檔案上傳的介面時,後報異常。Could not parse multipart servlet request; nested exception is java.io.IOException: The tem

關於springboot上傳檔案報錯:The temporary upload location ***is not valid

  在執行springboot時 ,長時間執行後報錯 the temporary uplaod location *** is not valid  查過資料後發現是centos對‘/temp’下檔案自動清理的原因。  在springboot專案啟動後 系統會在‘/temp’目

The temporary upload location is not valid

java.io.IOException: The temporary upload location [/tmp/tomcat.1593253653386650830.8220/work/Tomcat/localhost/ROOT] is not valid 最近我們的幾

Spring boot檔案上傳報錯: The temporary upload location is not valid

最近在做Excel匯入時,一次偶然的測試發現bug報錯如下: org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is

spring boot上傳檔案 The temporary upload location is not valid

Caused by: java.io.IOException: The temporary upload location [C:\Users\coffee\AppData\Local\Temp\tomcat.8572785615189560421.9999\w

關於使用webuploader上傳檔案出現的The temporary upload location is not valid

用webUploader外掛上傳檔案的時候,經常出現如下問題: 用google瀏覽器進行除錯,console頁問題如下: network頁問題如下: 下面我們重點看一下spring給我們提供的這幾個類裡面是如何對我這次請求進行處理的: 1、FrameWorkS

java.io.IOException: The temporary upload location [C:\Users\...\ROOT] is not valid

原文出處 spring boot 內部上傳檔案臨時儲存路徑不存在了,現在有兩種辦法: 第一種:專案重啟,自動重新生成臨時儲存路徑 第二種:注入一個Bean,手動添設定下臨時儲存路徑,程式碼如下: @Bean MultipartConfigElement

The temporary upload location [/tmp/tomcat.1337767218595042057.80/work/Tomcat/localhost/ROOT] is not

線上的系統中不能上傳檔案了,出現如下錯誤: org.springframework.web.multipart.MultipartException: Could not parse multip

Spring--《Spring實戰》The temporary upload location [/tmp/uploads] is not valid

在看《Spring實戰》第七章的時候,需要上傳檔案,書上說的是將上傳的圖片儲存在/tmp/uploads這個目錄下,因此我給專案的根路徑下建立了/tmp/uploads這個目錄,但是卻出現了標題中的錯誤,經過一番鬥爭之後,明白了問題的所在。 問題分析

nested exception is java.io.IOException: The temporary upload location

有一次請求post介面時報 Org.springframework.web.multipart.MultipartException: Could not parse multipart servle

spring boot 上傳檔案出錯:java.io.IOException: The temporary upload location

現象: 上傳excel,出現報錯: [Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Could not parse multipart

build case study 提示 the java db location is not set correctly

描述:在NetBeans的Services選項卡中右鍵啟動 Java DB時提示 the Java db location is not set correctly 解決方法:更改Java DB 的屬性,即右鍵 Java DB 選擇屬性 將Java DB Installation:位置

The run destination iPhone is not valid for running the scheme “xx”

真機執行,一直提示The run destination iOS Device is not valid for running the scheme,但是模擬器就沒有問題,更改 Deployment Target 也不行 最後發現,這應該是 Xcode 的

delphi 10.1編譯專案的時候出現MSBuildToolsPath is not specified for the ToolsVersion解決辦法

今天在使用delphi 10.1編譯專案的時候出現MSBuildToolsPath is not specified for the ToolsVersion "14.0" defined at

ImportError: The _imagingft C module is not installed

下載 .py pil www. .com gin 編譯 uci 網上 Python的圖形庫(PIL), 不過在官方下載了支持Python2.7的PIL Windows安裝包後,運行過程中發現會報_imagingft C module is not installed錯誤。

tomcat閃退無法啟動 the catalina_home environment variable is not defined correctly this environment variable is needed to run this program

新增 cor sta 啟動tomcat 計算 jdk版本 ogr jdk 環境變量 未成功配置CATALINA_HOME 1、計算機>屬性>環境變量, 新建環境變量。變量名為CATALINA_HOME ,變量值tomcat的解壓目錄,註意後面不用多加“\”或者

git更新失敗Probably the path to Git executable is not valid

alt size 路徑 cut val img 修改路徑 目錄 http git更新代碼失敗 檢查setting配置,發現路徑配置錯誤 找對git的安裝目錄,修改路徑後保存即可 git更新失敗Probably the path to Git executable

VMware安裝VMware tool是 遇到The path "" is not a valid path to the 3.10.0-693.el7.x86_64 kernel headers.

版本 ron not kernel nbsp valid header function install The path "" is not a valid path to the 3.10.0-693.el7.x86_64 kernel headers.問題是找不到內核

The string "--" is not permitted within comments.

uil epo AR exceptio ext wrap bat nts XP 最近用mybatis做開發的時候遇到這個錯:The string "--" is not permitted within comments. 經檢查是mapper.xml配置文件註解的時候出

如何處理VirtualBox啟動錯誤消息:The vboxdrv kernel module is not loaded

either pro without cimage 處理 local current class 解決 我在啟動minikube時,遇到如下錯誤消息: Starting local Kubernetes v1.10.0 cluster... Starting VM...