mybatis-spring整合总结02_SqlSessionFactoryBean
SqlSessionFactoryBean
在Mybatis中,SqlSessionFactoryBuilder用于创建SqlSessionFactory。而在Mybatis-Spring中SqlSessionFactoryBean将取而代之。
为了得到factory bean,如上节所示,需在Spring XML中配置:
SqlSessionFactoryBean实现了Spring的FactoryBean接口。这意味着Spring最终返回的不是SqlSessionFactoryBean而是作为factory 的getObject()方法返回的Object。这相当于下面的java代码: