1.检查SQL语句是否正确
2.检查yml文件中数据库连接路径是否正确
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/event
username: root
password: 123456
3.检查bean对象是否添加了@Autowired自动注入注解
4.mapper层中的方法有两个及以上的参数时,每个参数前要添加@Param注解
void add(@Param("username") String username, @Param("password") String password);