在Spring3 中使用多个数据库的方法, Spring可以参考

http://www.blogjava.net/youxia/archive/2009/07/15/286916.html
applicationContext.xml

由于配置了多个SessionFactory,所以需要在web.xml中配置两个OpenSessionInViewFilter,下面是我的web.xml文件:

由于项目中有多个SessionFactory,所以编写Dao层的时候需要使用@Resource注解来明确指定使用哪一个SessionFactory,如下面代码所示,ArticleDao使用sessionFactoryContent,而ArticleIndexDao使用sessionFactoryIndex: