SSM整合---配置文件方式

Spring--SpringMVC--Mybatis

目录

一、需要配置哪些文件

1.pom.xml

2.web.xml

3.springMvc.xml配置

4.mybatis-config.xml

5.spring.xml

二、配置文件

1.web.xml

2.web.xml

3.springMvc.xml

4.mybatis-config.xml

5.speing.xml


一、需要配置哪些文件

1.pom.xml

导入需要的依赖

2.web.xml

配置前端控制器DispatcherServlet

处理编码问题

处理请求方法的过滤器

配置监听器,在服务器启动的时候加载Spring的配置文件

3.springMvc.xml配置

扫描控制层

开启MVC注解驱动

配置视图控制器

静态资源不过滤

4.mybatis-config.xml

驼峰自动转换和日志功能

5.spring.xml

扫描组件(除去控制层)

配置数据源并连接数据库(我使用的是Druid)

配置事务管理器

整合Mybatis(配置SqlSessionFatoryBean)

配置mapper接口的扫描

二、配置文件

1.web.xml

  <groupId>org.example</groupId>
  <artifactId>12_ssm</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>



  <properties>
    <spring.version>5.2.9.RELEASE</spring.version>
  </properties>


  <!--spring需要的坐标-->
  <dependencies>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <!--加载bean-->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-beans</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <!--springMVC需要-->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <!--事务需要-->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <!--aop切面-->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-aspects</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <!--测试,配合junit-->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <!--  mybatis-->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>3.5.9</version>
    </dependency>
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis-spring</artifactId>
      <version>2.0.7</version>
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

涐啝雨の約定

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值