错误内容:
The error may exist in UserMapper.xml
### The error may involve test.selectAll
### The error occurred while executing a query
Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
看视频课的时候,跟着视频写配置文件,但还是报错Mybati快速入门那一节
如下
[DEBUG] [main] o.a.i.l.LogFactory - Logging initialized using 'class org.apache.ibatis.logging.slf4j.Slf4jImpl' adapter.
[DEBUG] [main] o.a.i.d.p.PooledDataSource - PooledDataSource forcefully closed/removed all connections.
[DEBUG] [main] o.a.i.d.p.PooledDataSource - PooledDataSource forcefully closed/removed all connections.
[DEBUG] [main] o.a.i.d.p.PooledDataSource - PooledDataSource forcefully closed/removed all connections.
[DEBUG] [main] o.a.i.d.p.PooledDataSource - PooledDataSource forcefully closed/removed all connections.
[DEBUG] [main] o.a.i.t.j.JdbcTransaction - Opening JDBC Connection
Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
### The error may exist in UserMapper.xml
### The error may involve test.selectAll
### The error occurred while executing a query
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
解决办法:出错原因是因为本地mysql版本与pom.xml内的版本不一致,导致:
可以先查看本地mysql版本
cmd 里输入
mysql --version
改为本机版本8.0.32即可 记得刷新一下pom
然后运行:即可