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