一、在Spring框架中有两个核心接口:BeanFactory和ApplicationContext,其中ApplicationContext是BeanFactory的子接口。他们都可代表Spring容器,Spring容器是生成Bean实例的工厂,并且管理容器中的Bean。
//启动spring容器
ApplicationContext ac = new ClassPathXmlApplicationContext("scope.xml");
其中scope.xml是Spring的配置文件,ApplicationContext是一个接口,ClassPathXmlApplicationContext是其一个实现类,而ApplicationContext实现了BeanFactory接口,拥有更多的实现方法。
总结:所以Spring容器负责管理Bean与Bean之间的依赖关系。容器中Bean处于容器管理下,无须主动访问容器,只需要接受容器的注入(DI)管理即可。同时Bean实例的依赖关系通常也是由容器注入,无须Bean实例主动请求
二、Hibernate的核心接口是Session,提供了对数据的增删改查操作
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml");
而Configuration接口的作用是对Hibernate进行配置,以及对它进行启动。在Hibernate的启动过程中,Configuration类的实例首先定位映射文档的位置,读取这些配置,然后创建一个SessionFactory对象。
三、MyBatis的核心类是SqlSession,SqlSession提供select/insert/update/delete方法,在旧版本中使用使用SqlSession接口的这些方法,但是新版的Mybatis中就会建议使用Mapper接口的方法。