1. 程式人生 > >spring boot 長時間執行上傳報臨時目錄找不到

spring boot 長時間執行上傳報臨時目錄找不到

The temporary upload location [/tmp/tomcat-docbase.3752410576653354473.8899/work/Tomcat/localhost/ROOT] is not valid at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)

 

解決1(centos7):好像隔了久些,還是報錯了。

    /**
     * 檔案上傳臨時路徑
     */
    @Bean
    public
MultipartConfigElement multipartConfigElement() { MultipartConfigFactory factory = new MultipartConfigFactory(); String tempUrl = FileUtil.getTempDirectoryPath() + File.separator + "senscrm"; System.out.println("臨時目錄:" + tempUrl); File file = new File(tempUrl);
if (!file.exists()) { file.mkdir(); } factory.setLocation(tempUrl); return factory.createMultipartConfig(); }
報錯: The temporary upload location [/tmp/senscrm] is not valid

解決2:

   在啟動的額環境變數裡面新增引數:-Djava.io.tmpdir = /xxx/tmp