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

 

猜你喜欢

转载自www.cnblogs.com/yjhkhnuje/p/9987197.html