@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)

后台提示:

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'apiStationOperationServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'apiStationOperationMapper' defined in file [D:\develop\code\project\svn-sunhr\non-trade\enterprise-networking\job-land-port-task\target\classes\com\xmeport\project\mapper\ApiStationOperationMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'multipleDataSource' defined in class path resource [com/xmeport/project/common/config/DruidAutoConfiguration.class]: Unsatisfied dependency expressed through method 'multipleDataSource' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'landPort' defined in class path resource [com/xmeport/project/common/config/DruidAutoConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'multipleDataSource': Requested bean is currently in creation: Is there an unresolvable circular reference?

译文:

在上下文初始化过程中遇到异常-取消刷新尝试:org.springframework.bean .factory。创建名为“apiStationOperationServiceImpl”的bean时出错:通过字段“baseMapper”表示的未满足依赖;嵌套异常是org.springframework.beans.factory。UnsatisfiedDependencyException:在文件[D:开发\代码\项目\svn-sunhr\非贸易\企业联网\工作-地-port-任务\目标\类\com\xmeport\项目\mapper\ apiStationOperationMapper]中定义的bean创建错误。类]:通过bean属性'sqlSessionFactory'表示的不满意依赖;嵌套异常是org.springframework.beans.factory。UnsatisfiedDependencyException:创建在类路径资源[com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration中定义名为“sqlSessionFactory”的bean时出错。类]:通过方法'sqlSessionFactory'参数0表示的未满足依赖;嵌套异常是org.springframework.beans.factory。创建名为“multipleDataSource”的bean时出现错误,该bean定义在类路径资源[com/xmeport/project/common/config/DruidAutoConfiguration]中。类]:通过方法'multipleDataSource'参数0表示的未满足依赖;嵌套异常是org.springframework.beans.factory。BeanCreationException:创建在类路径资源[com/xmeport/project/common/config/DruidAutoConfiguration]中定义名为“landPort”的bean时出现错误。初始化bean失败;嵌套异常是org.springframework.beans.factory。创建名为org.springframework.boot.autoconfigure.jdbc的bean时出现错误。DataSourceInitializerInvoker': init方法调用失败;嵌套异常是org.springframework.beans.factory。BeanCurrentlyInCreationException:创建名为“multipleDataSource”的bean错误:被请求的bean目前正在创建中:是否存在一个无法解决的循环引用?

 

异常提示:

***************************
APPLICATION FAILED TO START
***************************

Description:

The dependencies of some of the beans in the application context form a cycle:

   apiStationOperationServiceImpl (field protected com.xmeport.framework.mybatis.mapper.BaseMapper com.xmeport.framework.service.impl.BaseServiceImpl.baseMapper)
      ↓
   apiStationOperationMapper defined in file [D:\develop\code\project\svn-sunhr\non-trade\enterprise-networking\job-land-port-task\target\classes\com\xmeport\project\mapper\ApiStationOperationMapper.class]
      ↓
   sqlSessionFactory defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]
┌─────┐
|  multipleDataSource defined in class path resource [com/xmeport/project/common/config/DruidAutoConfiguration.class]
↑     ↓
|  landPort defined in class path resource [com/xmeport/project/common/config/DruidAutoConfiguration.class]
↑     ↓
|  org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker
└─────┘

 

Spring Boot会自动根据jar包的依赖来自动配置项目,例如当你项目下面有HSQLDB的依赖,Spring Boot会自动创建默认的内存数据库的数据源DataSource,

但我们使用Mybatis自定义配置,想自己创建DataSource时就必须注释掉DataSourceAutoConfiguration。

 

参考:

https://www.cnblogs.com/aspirant/p/10637284.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
# springboot 集成第三方框架测试学习 ~~~ springboot 2.0.4版本以上需配置数据源不然启动会报错或者启动类取消数据源自动注入(加入注解@EnableAutoConfiguration(exclude = DataSourceAutoConfiguration.class)) ~~~ * [springboot配置学习](https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-spring-application) ## 目前已经加入集成成功的demo * [SpringBoot+elasticsearch](./springboot-elasticsearch/README.md) * [SpringBoot+elasticsearch7.x](./springboot-elasticsearch7/README.md) * [SpringBoot+tkmapper](./springboot-tkmapper/README.md) * [SpringBoot+rabbitmq](./springboot-rabbitmq/README.md) * [SpringBoot+kafka](./springboot-kafka) * [SpringBoot+shiro(REAMDME.md RBAC 参考链接)](./springboot-shiro/README.md) * [SpringBoot+redis](./springboot-redis/README.md) * [SpringBoot+security](./springboot-security/README.md) * [SpringBoot+simple_security](./springboot-simple-security/README.md) * [SpringBoot+seaweedfs](./springboot-seaweedfs/README.md) ## 待测试 * [SpringBoot-fastdfs](./springboot-fdfs/README.md) ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值