赞
踩
【问题描述】:启动SpringBoot项目时,报如下堆栈错误
- 32.014 ERROR c.z.hikari.pool.HikariPool :594 restartedMain HikariPool-1 - Exception during pool initialization.
- com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
-
- The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
- at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
- at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
- at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:833)
- at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:453)
- at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
- at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
- at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
- at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364)
- at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
- at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476)
- at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
- at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
- at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
- at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:158)
- at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:116)
- at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
- at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:330)
- at org.springframework.boot.jdbc.EmbeddedDatabaseConnection.isEmbedded(EmbeddedDatabaseConnection.java:184)
- at org.springframework.boot.jdbc.init.DataSourceScriptDatabaseInitializer.isEmbeddedDatabase(DataSourceScriptDatabaseInitializer.java:64)
- at org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer.isEnabled(AbstractScriptDatabaseInitializer.java:87)
- at org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer.initializeDatabase(AbstractScriptDatabaseInitializer.java:74)
- at org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer.afterPropertiesSet(AbstractScriptDatabaseInitializer.java:65)
- at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1845)
- at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1782)
- at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:602)
- at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524)
- at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
- at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
- at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
- at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
- at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
- at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
- at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944)
- at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
- at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
- at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
- at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
- at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434)
- at org.springframework.boot.SpringApplication.run(SpringApplication.java:338)
- at com.abc.wiki.WikiApplication.main(WikiApplication.java:19)
- 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:498)
- at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
- Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
-
- The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
- 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:423)
- at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
- at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
- at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)
- at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167)
- at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:89)
- at com.mysql.cj.NativeSession.connect(NativeSession.java:144)
- at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:953)
- at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:823)
- ... 42 common frames omitted
- Caused by: java.net.ConnectException: Connection timed out: connect
- at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
- at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
- at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
- at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
- at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
- at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
- at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
- at java.net.Socket.connect(Socket.java:589)
- at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:155)
- at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:63)
- ... 45 common frames omitted
【问题原因】:今天在本地调试项目,由于电脑连接的wifi变了,导致ip也变了,最终导致这个问题。
【解决方法】:将项目连接数据库的配置修改为新的ip地址。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。