Multiple DataSource and JdbcTemplate in Spring Boot (> 1.1.0)

亡梦爱人 提交于 2019-11-30 02:46:16

Try to move @Qualifier annotation to the parameter on your @Bean methods for JdbcTemplate.

I guess, when you remove @Primary you end up with error, where more than one appropriate beans are presented

It should looks like this:

@Bean(name = "jdbcSlave")
@Autowired
public JdbcTemplate slaveJdbcTemplate(@Qualifier("dsSlave") DataSource dsSlave) {
    return new JdbcTemplate(dsSlave);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!