mybatis错误:Cause: java.lang.ClassNotFoundException: Cannot find class: ${com.mysql.cj.jdbc.Driver}

在配置mybatis-config.xml中常见的错误:

Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class: ${com.mysql.cj.jdbc.Driver}
### The error may exist in UserMapper.xml
### The error may involve test.selectAll
### The error occurred while executing a query
### Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class: ${com.mysql.cj.jdbc.Driver}
WeChatc1ecb0777f8c7c96de83a4269ce4788b.png

解决方法:
1、在pom.xml文件中查看自己安装的mysql和mysql驱动jar包(mysql-connector-java)、mybatis是否版本匹配
2、将mybatis-config.xml中配置的数据库信息,$和{}去掉


WeChatd8ef27dd7677c5b1ce843eb140eb4e56.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容