SSM框架整合中各xml文件的配置
1.mybatis.xml配置文件
- 在resources文件夹中创建mybatis-config.xml文件 因为我们进行框架整合,所以配置文件连接数据库的代码可交给applicationContext.xml文件进行
- 此时的mybatis-config.xml文件的配置十分少
- 如图

只有配置mybatis代码的日志或在mapper文件中sql语句返回的类型包的别名
2.applicationContext.xml配置文件
- 配置读取jdbc.properties
- 配置数据库连接:BasicDataSource
- 配置读取书写sql语句的mapper.xml文件的位置:SqlSessionFactoryBean
- 读取dao’层接口类 将dao接口与对应的xml文件关联:MapperScannerCoffigurer
- 如图

3.springmvc.xml配置文件
- 配置包扫描
- 开启springmvc注解驱动
- 配置视图解析器
- 如图

4.web.xml配置文件
- 配置spring.xml文件的路径
- 配置context 加载的监听器:ContextLoaderListener
- 配置springmvc核心类:DispatcherServlet
- 如图

5.resources文件夹中的配置文件
- 如图

6.web.xml配置文件
- 如图

本文详细介绍了SSM框架整合中的关键配置文件包括mybatis.xml、applicationContext.xml、springmvc.xml及web.xml等。通过这些配置文件实现了数据库连接、DAO层接口与XML文件的关联、Spring MVC的初始化等工作。
916

被折叠的 条评论
为什么被折叠?



