在运行springboot时 ,长时间运行后报错 the temporary uplaod location *** is not valid  查过资料后发现是centos对‘/temp’下文件自动清理的原因。  在springboot项目启动后 系统会在‘/temp’目录下创建几个目录 用于上传文件。因此清理过‘/temp’下文件后无法上传   

解决方法:    1 重启服务;

      2 改变临时文件的存储路径

关于springboot上传文件报错:The temporary upload location ***is not valid
@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();
     }    
}
    

相关文章:

  • 2021-09-09
  • 2021-12-16
  • 2021-12-09
  • 2021-05-16
  • 2022-12-23
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-29
  • 2021-08-07
  • 2021-07-01
  • 2022-12-23
  • 2022-01-14
  • 2022-12-23
  • 2021-08-20
相关资源
相似解决方案