Mybatis-config.xml
1.配置数据源
导入实体类,针对数据库创建的entity对象(也称之为pojo)
2.导入mapper.xml文件(即对数据库操作的文件)
在springboot文件中若复杂的sql需要采用mapper.xml文件格式时只需要在yml文件中的mybatis加入路径即可
mapper-locations: classpath*:mapper/*Mapper.xml
此路径代表为resources路径下的mapper文件夹下的所有结尾为Mapper.xml的文件
关于第二点的springboot使用mapper.xml可参考 点击
关于spring部分分为两部分
1.springdao.xml
1.关联数据库配置文件(即链接数据库的uname等信息,也可以直接在链接时写入)
2.连接池
3.sqlSessionFactory
4.配置Dao扫描,动态实现Dao接口注入spring中
(在springBoot中使用@mapper注解直接完成)
个人理解:将Mybatis的对数据库的操作通过这里连接起来,连接关系为连接dao接口,通过mapper.xml的namespace链接到mapper.xml从而实现基本的CRUD
2. spring-Service.xml
1.扫描Service下的所有包
2.将所有的业务类注入到spring,
3.声明事务或配置事务
4.AOP事务
springMVC
1.注解驱动
2.静态资源过滤
3.扫描controller
4.视图解析器
applicationContext.xml
将xml全部导入,进行整合
web.xml
1.dispatchServlet 将applicationContext.xml引入
2.乱码过滤器