The field imgFile exceeds its maximum permitted size of 1048576 bytes.显示文件的大小超出了允许的范围。
每个文件的配置最大为1Mb,单次请求的文件的总数不能大10Mb。要更改这个默认值需要在配置文件(application.properties)中加入两个配置。
multipart.maxFileSize=10Mb是设置单个文件的大小,
multipart.maxRequestSize=100Mb是设置单次请求的文件的总大小如果是想要不限制文件上传的大小,那么就把两个值都设置为-1就行啦
server:
port: 9292 #配置启动端口号
servlet:
context-path: /aa #配置启动项目名
spring:
thymeleaf:
cache: false
prefix: classpath:/templates/
suffix: .html
servlet:
multipart: #设置上传文件大小
enabled: true
max-file-size: 20MB #设置单个文件的大小
max-request-size: 20MB #设置单次请求的文件的总大小
datasource:
name: test #数据库名
url: jdbc:mysql://localhost:3306/dev?useSSL=false&characterEncoding=UTF-8 #url
username: root #用户名
password: root #密码
driver-class-name: com.mysql.jdbc.Driver #数据库链接驱动
web:
resources:
static-locations: classpath:/static/,file:${photo.file.dir} #暴露哪些资源可以通过项目名访问
mybatis:
mapper-locations: classpath:com/lgqyun/mapper/*.xml
type-aliases-package: cn.lgqyun.entity
# 日志配置
logging:
level:
root: info
com.baizhi: debug
# 指定文件上传位置
photo:
file:
dir: F:/myGit/ems/src/main/resources/static/img