@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

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