本文主要是介绍The last packet successfully received from the server was 123,051 milliseconds ago. The last packet,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
博客写的略水,所以提前把问题和解决问题的方式写在前面,遇到这个问题,首先分析下:
项目是不是多个数据源,事务配置是不是有问题。
查了百度,发现遇到这个问题的情况也不少,各种各样。
所以记录一下我遇到的问题和我解决的方式,望能给别人一点启发。
问题描述:
本地环境、测试服务器环境,应用启动,完全没有问题。
然后在一个镜像生产的数据库服务上启动(这个应用真是考验我的解决问题能力,也可能我的能力一般,所以总是被考验),然后应用启动就报了个错,
删去了业务系统的日志,大致如下:
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@35c12c7a]
[main] INFO org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializer.logAutoConfigurationReport -Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.[main] ERROR org.springframework.boot.SpringApplication.reportFailure - Application startup failed
java.lang.IllegalStateException: Failed to execute ApplicationRunnerat org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:726)at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:713)at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:703)at org.springframework.boot.SpringApplication.run(SpringApplication.java:304)at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)...............................................................Application.main(Application.java:86)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:497)at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failureThe last packet successfully received from the server was 123,051 milliseconds ago. The last packet sent successfully to the server was 10 milliseconds ago.at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:289)at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373)at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:447)at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:277)at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)... 14 common frames omitted
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failureThe last packet successfully received from the server was 195,051 milliseconds ago. The last packet sent successfully to the server was 10 milliseconds ago.at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)at java.lang.reflect.Constructor.newInstance(Constructor.java:422)at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:989)at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3559)at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3459)at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3900)at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527)at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680)at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486)at com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:4778)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:497)at org.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:126)at org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:108)at org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor.invoke(AbstractCreateStatementInterceptor.java:79)at org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:108)at org.apache.tomcat.jdbc.pool.DisposableConnectionFacade.invoke(DisposableConnectionFacade.java:81)at com.sun.proxy.$Proxy143.setAutoCommit(Unknown Source)at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:267)... 27 common frames omitted
Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:3011)at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3469)... 44 common frames omitted
[main] INFO
解决这个问题的方式和过程就不细说了。
问题原因:在insert的时候,spring的默认事务默认开启,然后就报了错。就是以上的错误。为了解决问题,所以把 【事务方式改成手动开启和关闭了】。然后就解决了。这个问题,我觉的查下资料就知道为啥了。我先忙了,项目delay了3天。
根据我查资料得出的结论是:多个数据源,使用默认事务的时候没有指定value,所以就。。。
这篇关于The last packet successfully received from the server was 123,051 milliseconds ago. The last packet的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!