今天的博客主题
SpringBoot ——》SpringBoot异常汇总
请求出现406
多半是在请求方法上的@RequestMapping注解上没有produces = "application/json;charset=UTF-8" 参数或者是你写了但是你的请求方法的返回类型与produces所指定的类型不一致。
文件上传异常(io.undertow.server.RequestTooBigException: UT000020: Connection terminated as request was larger than 10485760)
上传超过1M的文件出现异常
io.undertow.server.handlers.form.MultiPartParserDefinition$FileTooLargeException:
UT000054: The maximum size 1048576 for an individual file in a multipart request was exceeded
上传一个14.2M的文件出现异常:
第一次出现异常:413。搜索引擎发现是nginx配置大小的问题,修改之后。出现下面异常
io.undertow.server.RequestTooBigException: UT000020: Connection terminated as request was larger than 10485760
功能代码:
pom文件感觉比较重要一段
配置文件详细配置
本地环境无论如何测试始终没有问题,但是部署到测试环境就完蛋。
原来测试环境有网关服务,网关也会拦截上传文件的大小,默认1M
解决:在zuul网关项目增加配置
spring:
servlet:
multipart:
max-file-size: 512MB
max-request-size: 512MB
enabled: true
file-size-threshold: 0