SSM配置文件小结

Spring配置文件: applicationContext.xml
SprngMVC配置文件: spring-mvc.xml
MyBatis映射文件: AccountMapper.xml
MyBatis核心文件: sqlMapConfig.xml
数据库连接信息文件: jdbc.properties
Web.xml文件: web.xml
日志文件: log4j.xml

原始方式整合:不同文件的内容

MyBatis核心文件: sqlMapConfig.xml
<!--加载properties文件-->
<!--定义别名-->
<!--环境-->
<!--加载映射-->
MyBatis映射文件: AccountMapper.xml
一些sql语句
SprngMVC配置文件: spring-mvc.xml
<!--组件扫描  主要扫描controller-->
<!--配置mvc注解驱动-->
<!--内部资源视图解析器-->
<!--开放静态资源访问权限-->
Spring配置文件: applicationContext.xml
<!--组件扫描 扫描service和mapper-->
Web.xml文件: web.xml
<!--spring 监听器-->
<!--springmvc的前端控制器-->
<!--乱码过滤器-->  

Spring整合MyBatis:不同文件的内容

Spring配置文件: applicationContext.xml
SprngMVC配置文件: spring-mvc.xml
MyBatis映射文件: AccountMapper.xml
MyBatis核心文件: sqlMapConfig-spring.xml
数据库连接信息文件: jdbc.properties
Web.xml文件: web.xml
日志文件: log4j.xml

MyBatis核心文件: sqlMapConfig-spring.xml
<!--定义别名-->
Spring配置文件: applicationContext.xml
<!--    组件扫描 扫描service and mapper-->
<!--    加载propeties文件-->
<!--配置数据源信息-->
<!--配置sessionFactory-->,<!--加载mybatis核心文件-->
<!--扫描mapper所在的包 为mapper创建实现类--> 对应之前的加载映射文件

优点:Spring整合Mybatis 可以简化Service

原始方式整合:

MyBatis映射文件: AccountMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.itheima.mapper.AccountMapper">
    <select id="findAll" resultType="account">
        select * from account
    </select>
    <insert id="save" parameterType="account">
        insert into account values(#{id},#{name},#{money})
    </insert>
</mapper>

MyBatis核心文件: sqlMapConfig.xml

<!--核心文件头部-->
<!--加载properties文件-->
<!--定义别名-->
<!--环境-->
<!--加载映射-->

案例:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值