错误信息:The field file exceeds its maximum permitted size of 1048576 bytes
原因是因为SpringBoot内嵌tomcat默认所能上传的文件大小为1M,超出这个就会报错。

解决办法:

1.修改application.yml配置文件

spring:
http:
multipart:
enabled: true
max-file-size: 30MB
max-request-size: 30MB

2.编写配置类

package com.blog.springboot.config;

import javax.servlet.MultipartConfigElement;

import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; @Configuration
public class MulterFile {
/**
* 文件上传配置
* @return
*/
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
//文件最大
factory.setMaxFileSize("30960KB"); //KB,MB
/// 设置总上传数据总大小
factory.setMaxRequestSize("309600KB");
return factory.createMultipartConfig();
}
}

参考资料:
Spring Boot:The field file exceeds its maximum permitted size of 1048576 bytes.
Spring Boot设置上传文件大小

Spring Boot:The field file exceeds its maximum permitted size of 1048576 bytes的更多相关文章

  1. [转]Spring Boot修改最大上传文件限制:The field file exceeds its maximum permitted size of 1048576 bytes.

    来源:http://blog.csdn.net/awmw74520/article/details/70230591 SpringBoot做文件上传时出现了The field file exceeds ...

  2. The field file exceeds its maximum permitted size of 1048576 bytes.

    问题原因:Spring Boot内置tomcat限制了请求文件的大小 下面是修改方法:根据自己的Spring Boot版本 2.0之后版本的修改方式 在主配置文件 application.proper ...

  3. org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field xxx exceeds its maximum permitted size of 1048576 bytes.

    springboot 通过MultipartFile接受前端传过来的文件时是有文件大小限制的(springboot内置tomact的的文件传输默认为1MB),我们可以通过配置改变它的大小限制 首先在启 ...

  4. mariadb:InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes

    mariadb 启动中 InnoDB: Error: log file ./ib_logfile0 is of different size 0 起因:线上正在运行的系统,因为需要调整性能,变更了my ...

  5. The maximum column size is 767 bytes (Mysql)

     ERROR app.wsutils 419 INCRON: Error: ('HY000', '[HY000] [MySQL][ODBC 5.2(w) Driver][mysqld-5.7.7-rc ...

  6. mysql 1709: Index column size too large. The maximum column size is 767 bytes.

    1709: Index column size too large. The maximum column size is 767 bytes. 修改排序规则解决 utf8_general_ci

  7. Index column size too large. The maximum column size is 767 bytes.

    mysql建表时报Index column size too large. The maximum column size is 767 bytes.解决办法:在建表语句的后面加入:ENGINE=In ...

  8. InnoDB: Error: log file .\ib_logfile0 is of different size 0 10485760 bytes

    启动WAMP Server的时候报例如以下的错误: 140618 23:12:32 [Note] Plugin 'FEDERATED' is disabled. 140618 23:12:32 Inn ...

  9. ERROR 1709 (HY000): Index column size too large. The maximum column size is 767 bytes.

    MySQL版本5.6.35 在一个长度为512字符的字段上创建unique key报错 CREATE DATABASE dpcs_metadata DEFAULT CHARACTER SET utf8 ...

随机推荐

  1. 浅析java程序的执行过程

    在研究任何一门语言时,无论是面向过程的c,c++(面向过程和面向对象),还是面向对象的.net,java等,弄清语言执行过程至关重要.  何为语言执行过程? 所谓语言执行过程,指对于任何一门语言,如j ...

  2. 百度图片objURL解密vb.net版

    Function Baidtu_Uncomplie(k As String) As String Dim c = {"_z2C$q", "_z&e3B" ...

  3. [PHP] 频率限制类

    比如要实现 单个ip限制60秒1次单个关键字,比如手机号,限制60秒1次,3600秒10次 <?php class Sina_Mail_WebAntispam { const PREFIX_WH ...

  4. 配置javaJDK环境

    1.官网下载JDK包 2.解压包 3.打开vi /etc/profile文件添加一下内容 export JAVA_HOME=/usr/jdk1.8.0_121 #你的jdk所在的目录 export C ...

  5. 【大数据】了解Hadoop框架的基础知识

    介绍 此Refcard提供了Apache Hadoop,这是最流行的软件框架,可使用简单的高级编程模型实现大型数据集的分布式存储和处理.我们将介绍Hadoop最重要的概念,描述其架构,指导您如何开始使 ...

  6. webpack入门教程--1

    首先说什么是webpack:Webpack 是一个前端资源加载/打包工具.它将根据模块的依赖关系进行静态分析,然后将这些模块按照指定的规则生成对应的静态资源. 然后因为webpack有不同的版本,所以 ...

  7. 使用addviewController()实现无业务逻辑跳转

    需要实现WebMvcConfigurer类,重写addViewControllers方法. 添加@Configuration,等价于xml配置. package dbzx.config; import ...

  8. JAVA forname classnotfoundexception 错误

    今日在使用Class.forName方法的时候报了错误: JAVA forname classnotfoundexception 原因是Class.forName(className);里面的clas ...

  9. Fragment与Activity的接口回调

    这里说一个官方推荐的写法: private OnFragmentInteractionListener mListener; @Override public void onAttach(Contex ...

  10. Android注解神器 ButterKnife框架

    前言: 本人是一个只有几个月工作经验的码小渣.这是我写的第一篇博客,如有不足之处还请大家不要介意,还请大佬可以指出问题. 在这几个月的实战开发中自己也遇到了很多问题,真的是举步艰难啊!!! 在实战开发 ...