上传图片把数据存储到数据库时,报错
?Cause: com.mysql.cj.jdbc.exceptions.PacketTooBigException: Packet for query is too large (5,922,670 > 4,194,304). You can change this value on the server by setting the 'max_allowed_packet' variable. ; Packet for query is too large (5,922,670 > 4,194,304). You can change this value on the server by setting the 'max_allowed_packet' variable.; nested exception is com.mysql.cj.jdbc.exceptions.PacketTooBigException: Packet for query is too large (5,922,670 > 4,194,304). You can change this value on the server by setting the 'max_allowed_packet' variable. ?? ?at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:110) ?? ?at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) ?? ?at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) ?? ?at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) ?? ?at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73) ?? ?at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) ?? ?at com.sun.proxy.$Proxy110.insert(Unknown Source) ?? ?at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:278) ?? ?at com.baomidou.mybatisplus.core.override.PageMapperMethod.execute(PageMapperMethod.java:68) ?? ?at com.baomidou.mybatisplus.core.override.PageMapperProxy.invoke(PageMapperProxy.java:64) ?? ?at com.sun.proxy.$Proxy200.insert(Unknown Source) ?? ?at com.seal.user.service.impl.LogoServiceImpl.saveLogo(LogoServiceImpl.java:60) ?? ?at com.seal.user.service.impl.LogoServiceImpl$$FastClassBySpringCGLIB$$8667ca14.invoke(<generated>) ?? ?at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ?? ?at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:684) ?? ?at com.seal.user.service.impl.LogoServiceImpl$$EnhancerBySpringCGLIB$$285f9285.saveLogo(<generated>) ?? ?at com.seal.user.service.impl.LogoServiceImpl$$FastClassBySpringCGLIB$$8667ca14.invoke(<generated>) ?? ?at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ?? ?at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:684) ?? ?at com.seal.user.service.impl.LogoServiceImpl$$EnhancerBySpringCGLIB$$1287ac5b.saveLogo(<generated>) ?? ?at com.seal.user.service.impl.LogoServiceImpl$$FastClassBySpringCGLIB$$8667ca14.invoke(<generated>) ?? ?at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ?? ?at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:684) ?? ?at com.seal.user.service.impl.LogoServiceImpl$$EnhancerBySpringCGLIB$$1287ac5b.saveLogo(<generated>) ?? ?at com.seal.user.controller.LogoController.save(LogoController.java:26) ?? ?at com.seal.user.controller.LogoController$$FastClassBySpringCGLIB$$3fbd481a.invoke(<generated>) ?? ?at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ?? ?at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749) ?? ?at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ?? ?at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:62) ?? ?at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ?? ?at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:56) ?? ?at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ?? ?at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:55) ?? ?at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ?? ?at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93) ?? ?at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ?? ?at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) ?? ?at com.seal.user.controller.LogoController$$EnhancerBySpringCGLIB$$8056279b.save(<generated>) ?? ?at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ?? ?at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ?? ?at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ?? ?at java.lang.reflect.Method.invoke(Unknown Source) ?? ?at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ?? ?at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ?? ?at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) ?? ?at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892) ?? ?at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797) ?? ?at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ?? ?at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039) ?? ?at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) ?? ?at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) ?? ?at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908) ?? ?at javax.servlet.http.HttpServlet.service(HttpServlet.java:665) ?? ?at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882) ?? ?at javax.servlet.http.HttpServlet.service(HttpServlet.java:750) ?? ?at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ?? ?at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ?? ?at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ?? ?at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ?? ?at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ?? ?at brave.servlet.TracingFilter.doFilter(TracingFilter.java:65) ?? ?at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ?? ?at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ?? ?at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108) ?? ?at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137) ?? ?at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) ?? ?at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ?? ?at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ?? ?at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61) ?? ?at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108) ?? ?at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137) ?? ?at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) ?? ?at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66) ?? ?at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108) ?? ?at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137) ?? ?at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) ?? ?at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66) ?? ?at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:450) ?? ?at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) ?? ?at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) ?? ?at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) ?? ?at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387) ?? ?at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) ?? ?at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) ?? ?at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ?? ?at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ?? ?at com.seal.common.config.filter.CorsFilter.doFilter(CorsFilter.java:42) ?? ?at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ?? ?at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ?? ?at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:88) ?? ?at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) ?? ?at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ?? ?at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ?? ?at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ?? ?at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) ?? ?at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ?? ?at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ?? ?at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92) ?? ?at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) ?? ?at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ?? ?at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ?? ?at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) ?? ?at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) ?? ?at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ?? ?at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ?? ?at org.springframework.cloud.sleuth.instrument.web.ExceptionLoggingFilter.doFilter(ExceptionLoggingFilter.java:50) ?? ?at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ?? ?at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ?? ?at brave.servlet.TracingFilter.doFilter(TracingFilter.java:82) ?? ?at org.springframework.cloud.sleuth.instrument.web.TraceWebServletAutoConfiguration$LazyTracingFilter.doFilter(TraceWebServletAutoConfiguration.java:143) ?? ?at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ?? ?at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ?? ?at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:114) ?? ?at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:104) ?? ?at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) ?? ?at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ?? ?at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ?? ?at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) ?? ?at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) ?? ?at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ?? ?at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ?? ?at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ?? ?at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) ?? ?at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526) ?? ?at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) ?? ?at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ?? ?at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ?? ?at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) ?? ?at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) ?? ?at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) ?? ?at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860) ?? ?at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587) ?? ?at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ?? ?at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ?? ?at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ?? ?at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ?? ?at java.lang.Thread.run(Unknown Source) Caused by: com.mysql.cj.jdbc.exceptions.PacketTooBigException: Packet for query is too large (5,922,670 > 4,194,304). You can change this value on the server by setting the 'max_allowed_packet' variable.
?这是longblob和blob字段类型的数据默认大小的问题.
命令:
show variables like '%max_allowed_packet%';
?修改下默认大小,改为12M,命令:
set global max_allowed_packet = 12*1024*1024;
最后重启mysql
net stop mysql;
net start mysql;
=========================================================================
|