Mybatis 或者 数据库连接查询报错

用 mybatis-plus 插件自动生成的 selectByExample 或者 自己写的 sql 都会报错

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: 

Error creating bean with name ‘agvsCache‘: 
Invocation of init method failed; 
nested exception is org.mybatis.spring.MyBatisSystemException: 
nested exception is org.apache.ibatis.exceptions.PersistenceException: 

### Error querying database.  Cause: java.lang.NullPointerException
### The error may exist in cn/moviebook/wss/dao/recordmapper/TAgvMapper.xml
### The error may involve cn.moviebook.wss.dao.recordmapper.TAgvMapper.queryAllAgvs
### The error occurred while executing a query
### Cause: java.lang.NullPointerException

    2021-08-07 16:58:57.361  INFO 21356 --- [  restartedMain] com.alibaba.druid.pool.DruidDataSource   : {dataSource-1} closed
2021-08-07 16:58:57.364  INFO 21356 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2021-08-07 16:58:57.374  INFO 21356 --- [  restartedMain] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug‘ enabled.
2021-08-07 16:58:57.394 ERROR 21356 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name ‘agvsCache‘: 
Invocation of init method failed; 
nested exception is org.mybatis.spring.MyBatisSystemException: 
nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.NullPointerException
### The error may exist in cn/moviebook/wss/dao/recordmapper/TAgvMapper.xml
### The error may involve cn.moviebook.wss.dao.recordmapper.TAgvMapper.queryAllAgvs
### The error occurred while executing a query
### Cause: java.lang.NullPointerException
  1. 去掉防火墙 wall 不管用

  2. 把 sql 直接写在 mapper 里面,不用 mybatis ,还是不管用

  3. 把 AGV 初始化 注释掉,只初始化其他的资源,还是不管用

这样就确定了不是 sql 的问题,而是 mybatis 的问题

继续看下面的错误报告

提到了 mybatismybatis-plus 于是更新一下 mybatis-plus 的插件到最新版本

解决

Mybatis 或者 数据库连接查询报错

上一篇:图文实例解析,InnoDB 存储引擎中行锁的三种算法


下一篇:Oracle必须要启动的服务