Multiple DataSource and JdbcTemplate in Spring Boot (> 1.1.0)

前端 未结 2 1334
天涯浪人
天涯浪人 2020-12-25 10:46

I would like to inject a specific JdbcTemplatein a Spring Boot project. I tried to follow this example for multiple DataSourceconfiguration : http:

相关标签:
2条回答
  • 2020-12-25 11:28

    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

    0 讨论(0)
  • 2020-12-25 11:28

    It should looks like this:

    @Bean(name = "jdbcSlave")
    @Autowired
    public JdbcTemplate slaveJdbcTemplate(@Qualifier("dsSlave") DataSource dsSlave) {
        return new JdbcTemplate(dsSlave);
    }
    
    0 讨论(0)
提交回复
热议问题