spring配置多个数据源bug
澳门新葡京官网
澳门新葡京官网
当前位置 : 澳门新葡京官网 > 新葡京娱乐场

spring配置多个数据源bug

<bean id="dataSource" class="com.wacai.datamigration.configs.DynamicDataSource">

    <property name="targetDataSources">
        <!-- 制定lookupKey和与之对应的数据源 -->
        <map key-type="java.lang.String">
            <entry key="donghuaDataSource" value-ref="donghuaDataSource"/>
            <entry key="adanosDataSource" value-ref="adanosDataSource"/>
        </map>
    </property>
    <!-- 指定默认数据源 -->
    <property name="defaultTargetDataSource" ref="donghuaDataSource"/>
</bean>

报错如下:
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.

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

栏目列表

广告位

澳门新葡京官网