spring boot启动时mybatis报循环依赖错误的解决方法

spring boot启动时mybatis报循环依赖错误的解决方法

这篇文章主要介绍spring boot启动时mybatis报循环依赖错误的解决方法,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

在做项目时,想使用热部署减少部署时间,于是添加了springboot-devtools

在maven中添加了依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-devtools</artifactId>
</dependency>

然后正常的启动项目时发现控制台一直在不停的输出错误,错误如图

spring boot启动时mybatis报循环依赖错误的解决方法

spring boot启动时mybatis报循环依赖错误的解决方法

不明所以,然后就准备去调试下源码,在进入到了MybatisAutoConfiguration.java中

spring boot启动时mybatis报循环依赖错误的解决方法

画线的地方是出错的地方,报了空指针,这个properties是什么的

@Autowired
private MybatisProperties properties;

这个类从spring中注入的,那这个类是干什么的、什么时候注入的呢?先看下这个类的结构

spring boot启动时mybatis报循环依赖错误的解决方法

这就是读取我们再application.yml/properties中有关mybatis的配置。

为什么配置会读不到呢?之前都是好的。猜测是devtool搞的鬼,把依赖去掉果然就好了。

以上是“spring boot启动时mybatis报循环依赖错误的解决方法”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注行业资讯频道!