启动项目报错

来源:6-4 实例1-DB-DB

慕圣502602

2019-08-14

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘userJdbcTemplate’ defined in class path resource [com/imooc/example/springdtxdbdb/service/DBConfiguration.class]: Unsatisfied dependency expressed through method ‘userJdbcTemplate’ parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userDataSource’ defined in class path resource [com/imooc/example/springdtxdbdb/service/DBConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker’: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type ‘org.springframework.boot.autoconfigure.jdbc.DataSourceProperties’ available: more than one ‘primary’ bean found among candidates: [userDataSourceProperties, orderDataSourceProperties, spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties]

写回答

1回答

大漠风

2019-08-19

通过错误,可以看出,是配置了2个DataSourceProperties,但是好像没有设置"@Primary"。

可以贴你的config的配置类,看一下是哪里有问题。

0
0

分布式事务实践,从原理到实例,解决数据一致性

掌握分布式事务实现技术,是架构师必备技能。

1149 学习 · 153 问题

查看课程