错误1 核心配置文件(mybatis-config.xml)没有 注册映射文件(EmpMapper.xml)
org.apache.ibatis.binding.BindingException: Type interface com.jx.dao.EmpMapper is not known to the MapperRegistry.
如何修改 在核心配置文件中注册映射文件 mybatis-config.xml
<!--指定 映射器-->
<mappers>
<mapper resource="mapper/EmpMapper.xml"/>
<mapper resource="mapper/DeptMapper.xml"/>
<mapper resource="mapper/EmpPlusMapper.xml"/>
</mappers>
错误2 数据库服务未打开
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
### The error may exist in mapper/EmpMapper.xml
### The error may involve com.jx.dao.EmpMapper.findAllEmp2
### The error occurred while executing a query
### Cause: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
...
Caused by: java.net.ConnectException: Connection refused: connect
错误解决方案 打开mysql服务
Win+R 输入 services.msc
错误3 SQL语句编写错误
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'emp e,dept d
WHERE e.deptno=d.deptno' at line 8
### The error may exist in mapper/EmpMapper.xml
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT e.empno,e.ename,e.job,e.mgr,e.hiredate,e.sal,e.comm,e.deptno , d.deptno, d.dname, d.loc form emp e,dept d WHERE e.deptno=d.deptno
### Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'emp e,dept d
WHERE e.deptno=d.deptno' at line 8
映射文件当中编写的sql语句有语法错误
检查SQL语句 找到错误