使用mybatis时,出现异常
项目场景:
配置完成MyBatis后运行出现异常
问题描述
pom.xml配置文件内容如下
4.0.0 io.delightedqian mybatis-demo 1.0-SNAPSHOT org.mybatis mybatis 3.5.5
mysql mysql-connector-java 5.1.46
junit junit 4.13 test org.slf4j slf4j-api 1.7.20 ch.qos.logback logback-classic 1.2.3 ch.qos.logback logback-core 1.2.3
mybatis-config.xml文件
UserMapper.xml配置文件
各项配置文件都没有错 但是运行出现如下异常
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
原因分析:
MySQL的驱动jar包的版本问题
解决方案:
将5.1.32 改为5.1.46
mysql mysql-connector-java 5.1.32
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
