zoukankan      html  css  js  c++  java
  • SpringBoot设置tomcat临时文件目录必要性

    问题:

    SpringBoot运行一段时间之后,上传文件报错:
    The temporary upload location [/tmp/tomcat.****/work/Tomcat/localhost/ROOT] is not valid.

    分析:

    • SpringBoot默认以内置的tomcat启动,默认会在linux系统/tmp目录下创建工作目录(临时文件目录)。
    • SpringBoot使用内置tomcat上传文件时,会在tomcat临时文件目录下创建临时文件。
    • Linux系统默认会在一定时间时定时清理删除/tmp目录下的文件目录。

    因此,不重新配置tomcat临时文件目录或者不修改Linux定时清理/tmp目录的策略,会导致SpringBoot项目运行一段时间后,上传文件失败。

    解决方案:

    • 方案一:修改Linux系统定时清理/tmp目录策略。
    • 方案二:重新设置tomcat临时文件目录。(推荐)
    server:
        tomcat:
            basedir: ${tempDirPath}
  • 相关阅读:
    CSS样式2
    页面布局
    CSS样式1
    HTML
    Document
    Document
    Document
    Document
    Document
    Document
  • 原文地址:https://www.cnblogs.com/gavincoder/p/13794913.html
Copyright © 2011-2022 走看看