@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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章