多数据源 + Configuration中bean依赖注入顺序问题

 

 

 为什么要调用方法,而不是直接autowire?

 

 

官方文档 https://docs.spring.io/spring-boot/docs/current/reference/html/howto-data-access.html#howto-two-datasources

参考实现 https://www.liaoxuefeng.com/article/001484212576147b1f07dc0ab9147a1a97662a0bd270c20000

数据源datasource创建后,创建jdbcTemplate需要传入datasource, 直接在方法参数中传入

 

 其他方案:AOP切面+ThreadLocal+注解

场景:多数据源配置

 

posted @ 2018-10-31 21:17  funny_coding  阅读(1496)  评论(0编辑  收藏  举报
build beautiful things, share happiness