ssm项目整合中 mysql jar包版本问题

ssm项目整合中 mysql jar包版本问题

      • IDEA报错:
      • 错误原因
      • 解决
      • 结果

IDEA报错:

log4j:WARN No appenders could be found for logger (com.mchange.v2.log.MLog).
log4j:WARN Please initialize the log4j system properly.

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.SQLException: Connections could not be acquired from the underlying database!
### The error may exist in com/ricky/dao/BookMapper.xml
### The error may involve com.ricky.dao.BookMapper.queryAllBook
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!

错误原因

我使用的MySQL是8.0.19版本的:
ssm项目整合中 mysql jar包版本问题_第1张图片
而导入的MySQL jar包为
ssm项目整合中 mysql jar包版本问题_第2张图片

解决

MySQL jar包改为8.0.19即可

<dependency>
	<groupId>mysql</groupId>
	<artifactId>mysql-connector-java</artifactId>
	<version>8.0.19</version>
</dependency>

结果

重新运行,查询结果正确
在这里插入图片描述

你可能感兴趣的:(ssm项目整合中 mysql jar包版本问题)