Use AbstractRoutingDataSource to dynamicly switch datasources, see http://spring.io/blog/2007/01/23/dynamic-datasource-routing.

PS: note the use of ThreadLocal; may conflict with the use of SqlSessionTemplate.
 
 

相关文章: