栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

SSM整合步骤

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SSM整合步骤

1、导入需要的包

  
    
    
    
    
      junit
      junit
      4.12
      test
    
    
    
      mysql
      mysql-connector-java
      5.1.41
    
    
    
      com.mchange
      c3p0
      0.9.5.2
    
    
    
      javax.servlet
      servlet-api
      2.5
    
    
    
      javax.servlet
      jsp-api
      2.0
    
    
    
      jstl
      jstl
      1.2
    
    
    
      org.mybatis
      mybatis
      3.4.2
    
    
    
      org.mybatis
      mybatis-spring
      1.3.1
    
    
    
      org.springframework
      spring-webmvc
      5.2.7.RELEASE
    
    
    
      org.springframework
      spring-jdbc
      5.2.7.RELEASE
    
    
      org.junit.jupiter
      junit-jupiter
      RELEASE
      compile
    
    
    
      org.aspectj
      aspectjweaver
      1.9.6
      runtime
    
  

2、建立目录结构

3、创建数据库
4、编写对应各层的类

dao 中的方法

5、进行配置,spring的xml文件配置

spring 配置文件的头文件



mybatis 配置文件的头文件



    

Dao对应的xml文件的头文件



    

spring的配置


    
    
        
    
    
    
    
    
        
        
        
        
    
    
    
        
        
    
    
    
        
        
    
    
    
        
    
    
    
        
            
            
        
    
    
    
        
        
    

6、进行maybtis和对应dao接口的xml文件配置
mybatis核心文件的配置



    
        
    
    
        
    

对应dao的xml文件



    
        insert into account(name,money) values(#{name},#{money})
    
    
        delete from account where id = #{id}
    
    
        update account set name = #{name}, money = #{money} where id = #{id}
    
    
        select * from account
    

经过上面的步骤 ,spring和mybatis已经整合完成

7、进行web.xml 的配置




  Archetype Created Web Application
  
  
    contextConfigLocation
    classpath:ApplicationContext.xml
  
  
  
    characterEncodingFilter
    org.springframework.web.filter.CharacterEncodingFilter
    
      encoding
      UTF-8
    
  
  
    characterEncodingFilter
    /*
  
  
  
    org.springframework.web.context.ContextLoaderListener
  
  
  
    dispatcherServlet
    org.springframework.web.servlet.DispatcherServlet
    
      contextConfigLocation
      classpath:SpringMvc.xml
    
    1
  
  
    dispatcherServlet
    /
  

8、进行springmvc文件的配置
springmvc 头文件






    
    
        
    
    
    
        
        
    
    
    

ssm整合完成

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/331632.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号