一个新项目,由于需要远程办公,连接VPN后使用navicat等数据库连接工具的时候可以正常访问数据库,但启动项目时无法连接到数据库,报错信息如下:
Could not create connection to database server. Attempted reconnect 3 times. Giving up.
java.lang.IllegalStateException: Failed to execute ApplicationRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:798)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:785)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:345)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1356)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1345)
at cn.avicnet.cutter.selection.web.CutterSelectionServiceApplication.main(CutterSelectionServiceApplication.java:18)
Caused by: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
### The error may exist in cn/avicnet/cutter/selection/system/mapper/app/AreaMapper.java (best guess)
### The error may involve cn.avicnet.cutter.selection.system.mapper.app.AreaMapper.selectList
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.