1、问题
Exception in thread “main” org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘actTaskLockController’: Injection of resource dependencies failed
Caused by: java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2、原因
在Spring容器中,某个需要sqlSessionFactory或sqlSessionTemplate的组件(通常是MyBatis的Mapper接口或者Dao接口)没有获得这两个属性中的任何一个。
缺少配置:在Spring的配置文件(XML)或注解配置中,没有为MyBatis Mapper接口或Dao接口指定sqlSessionFactory或sqlSessionTemplate。
配置错误:指定了sqlSessionFactory或sqlSessionTemplate,但可能配置错误(如Bean名称错误、配置顺序问题、配置位置问题等)导致Spring容器无法正确注入。
依赖未加载:sqlSessionFactory或sqlSessionTemplate的依赖(如数据源、MyBatis配置文件等)没有正确加载或配置。
版本冲突:使用的MyBatis和Spring版本之间可能存在兼容性问题,导致无法正确集成。
3、解决
通过排查发现是版本问题,故升级Mybatis Plus版本。
升级mybatis-plus-boot-starter由2.3至3.5.3.2
Mybatis-plus升级(2.3至3.5):https://blog.csdn.net/qq_38254635/article/details/141162096
问题解决。
OK,就这些吧。
有什么不对的还望指正,书写不易,觉得有帮助就点个赞吧!☺☺☺
参考链接:
https://blog.csdn.net/2301_79779756/article/details/138369342
https://blog.csdn.net/weixin_43663420/article/details/132548707