java - spring配置多个数据源bug

 当时桃花恨春风_375 发布于 2022-10-31 15:43

    
        
        
            
            
        
    
    
    

报错如下:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'taskController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wacai.datamigration.services.BusinessControlManager com.wacai.datamigration.controllers.TaskController.businessControlManager; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'businessControlManager': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wacai.datamigration.services.DataServiceDispatch com.wacai.datamigration.services.BusinessControlManager.dataServiceDispatch; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataServiceDispatch' defined in file [E:wacaiworkspaceData-Migrationtargetclassesspringbean-spring.xml]: Cannot create inner bean 'com.wacai.datamigration.services.test.TestService#2024293c' of type [com.wacai.datamigration.services.test.TestService] while setting bean property 'dataServiceMap' with key [TypedStringValue: value [test], target type [null]]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.wacai.datamigration.services.test.TestService#2024293c': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wacai.datamigration.dao.test.TestDao com.wacai.datamigration.services.test.TestService.testDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wacai.datamigration.mapper.test.TestsMapper com.wacai.datamigration.dao.test.TestDao.testsMapper; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'testsMapper' defined in file [E:wacaiworkspaceData-MigrationtargetclassescomwacaidatamigrationmappertestTestsMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': : Error creating bean with name 'sqlSessionFactory' defined in file [E:wacaiworkspaceData-Migrationtargetclassesspringdatabase.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in file [E:wacaiworkspaceData-Migrationtargetclassesspringdatabase.xml]: Cannot resolve reference to bean 'donghuaDataSource' while setting bean property 'targetDataSources' with key [TypedStringValue: value [donghuaDataSource], target type [class java.lang.String]]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'donghuaDataSource' defined in file [E:wacaiworkspaceData-Migrationtargetclassesspringdatabase.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to decrypt.; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in file [E:wacaiworkspaceData-Migrationtargetclassesspringdatabase.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in file [E:wacaiworkspaceData-Migrationtargetclassesspringdatabase.xml]: Cannot resolve reference to bean 'donghuaDataSource' while setting bean property 'targetDataSources' with key [TypedStringValue: value [donghuaDataSource], target type [class java.lang.String]]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'donghuaDataSource' defined in file [E:wacaiworkspaceData-Migrationtargetclassesspringdatabase.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to decrypt.

1 个回答
  • 你所展示的这个XML片段没有问题,看起来你的问题好像是value-ref="donghuaDataSource",建议把配置文件补全。

    2022-10-31 22:58 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有