bug描述
***************************
APPLICATION FAILED TO START
***************************
Description:
The dependencies of some of the beans in the application context form a cycle:
userController (field private com.cy.order.service.IUserService com.cy.order.controller.UserController.userService)
↓
userServiceImpl (field protected com.baomidou.mybatisplus.core.mapper.BaseMapper com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.baseMapper)
↓
userMapper defined in file [D:\IntelliJ IDEA 2018.3.4\IdeaProjects\order\target\classes\com\cy\order\mapper\UserMapper.class]
↓
sqlSessionFactory defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]
┌─────┐
| dataSource defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]
↑ ↓
| org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker
└─────┘
Action:
Relying upon circular references is discouraged and they are prohibited by default. Update your application to remove the dependency cycle between beans. As a last resort, it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true.
Process finished with exit code 1
bug大致意思是不鼓励依赖循环引用,并且默认情况下禁止循环引用。更新应用程序以删除bean之间的依赖循环。作为最后的手段,可以通过将spring.min.allow-circular-references设置为true来自动打破循环。
bug解决办法
SpringBoot2.6正式发布:循环依赖默认禁止。如上提供解决方案为将spring.main.allow-circular-references 设置为 true,来自动中断循环。
如果是.properties文件,在文件中添加
spring.main.allow-circular-references=true
如果是.yml文件,在文件中添加
spring:
main:
allow-circular-references:true
重新启动项目,问题解决!