zoukankan      html  css  js  c++  java
  • 【异常】The dependencies of some of the beans in the application context form a cycle

    一、异常出现场景以及异常信息

    场景:SpringBoot中自定义DataSource数据源

    异常信息:

    2019-11-21 14:27:30.807 ERROR 5662 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
    
    ***************************
    APPLICATION FAILED TO START
    ***************************
    
    Description:
    
    The dependencies of some of the beans in the application context form a cycle:
    
       userServiceImpl (field com.zbq.springbootdemo.dao.UserDao com.zbq.springbootdemo.service.UserServiceImpl.userDao)
          ↓
       userDao defined in file [/Users/zhangboqing/Software/MyGithub/spring-boot-demo/target/classes/com/zbq/springbootdemo/dao/UserDao.class]
          ↓
       sqlSessionFactory defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]
    ┌─────┐
    |  dynamicDataSource defined in class path resource [com/zbq/springbootdemo/config/multidatasource/DataSourceConfig.class]
    ↑     ↓
    |  primary defined in class path resource [com/zbq/springbootdemo/config/multidatasource/DataSourceConfig.class]
    ↑     ↓
    |  org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker

    二、解决方案

    排除Spring Boot数据源自动配置类

    // 自定义数据源一定要排除SpringBoot自动配置数据源,不然会出现循环引用的问题,The dependencies of some of the beans in the application context form a cycle
    @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
  • 相关阅读:
    mysql 获取字符串的长度
    mysql 字符类以及重复元字符
    mysql 字段拼接
    mysql 去除字符串中的空格
    mysql 正则表达式
    mysql 选出前五个元素
    mysql regexp 表达式
    mysql 选择所有同学名字
    mysql 获取数学成绩最高以及最低的同学
    mysql 获取单个科目的平均分
  • 原文地址:https://www.cnblogs.com/756623607-zhang/p/11908513.html
Copyright © 2011-2022 走看看