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

初学者的java学习笔记——SSM整合

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

初学者的java学习笔记——SSM整合

SSM整合 导入依赖

1.spring-webmvc(spring核心依赖)

2.mybatis(mybatis依赖)

3.mysql-connector-java(mysql)

4.druid(连接池)

5.lombok(注解生成方法)

6.mybatis-spring(spring跟mybatis整合依赖)

7.jackson-databind(前后端开发分离)

8.spring-orm(整合的扩展包)

Spring+Spring MVC整合

配置spring-context.xml




    

配置文件spring-mvc.xml




    
    
    
Spring+Mybatis 配置spring-mybatis.xml

1.注册SqlSessionFactoryBean

a.注册所有的mapper.xml文件(在resources中新建mapper文件夹)

b.配置数据库连接池

c.指定核心配置文件

d.配置别名

spring-mybatis.xml 部分代码:


        

        

        

        
配置mybatis-config.xml



    

        
    
在resources中创建mapper文件夹并在其中创建与entity层一一对应的Mapper.xml 注册所有的接口

spring-mybatis.xml部分代码


        
        
    

Spring+Druid

配置spring-mybatis.xml数据库连接池

spring-mybatis.xml





    
        

        

        

        

    


    
        
        
    


    

        
        
        

        
        
        


        
        
        
        
        
        
        
        
        
    

开发

配置web.xml



  Archetype Created Web Application

  
    org.springframework.web.context.ContextLoaderListener
  

  
    contextConfigLocation
    classpath:spring-*.xml
  

  
    dispatcherServlet
    org.springframework.web.servlet.DispatcherServlet

    
      contextConfigLocation
      classpath:spring-mvc.xml
    
  
  

  dispatcherServlet
  /*



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

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

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