SSM整合

SSM整合,第1张

SSM整合 ssm整合配置文件  1.新建一个maven项目

        (1):maven的注意事项

                1)maven版本问题:

maven与idea版本关系:

1.IDEA22021兼容maven3.8.1以及之前的版本

2.IDEA2020兼容maven3.6.3以及之前的版本

3.IDEA2018兼容maven3.6.1以及之前的版本

 因版本不对提示的报错信息:

Unable to import maven project: See logs for details

 日志中的信息:

2021-12-22 19:48:40,564 [ 690796]  ERROR - plication.impl.ApplicationImpl - Last Action: ShowIntentionActions 
2021-12-22 19:48:40,564 [ 690796]  ERROR - plication.impl.ApplicationImpl - Current Command: Add Xsi schema location for external resource 
2021-12-22 19:48:40,564 [ 690796]  ERROR - plication.impl.ApplicationImpl - Read access is allowed from event dispatch thread or inside read-action only (see com.intellij.openapi.application.Application.runReadAction())
Details: Current thread: Thread[ApplicationImpl pooled thread 16,4,main] 1247386853
; dispatch thread: false; isDispatchThread(): false
SystemEventQueueThread: Thread[AWT-EventQueue-0 2017.3.4#IU-173.4548.28 IDEA, eap:false, os:Windows 10 10.0, java-version:JetBrains s.r.o 1.8.0_152-release-1024-b11,6,main] 752748039 
java.lang.Throwable: Read access is allowed from event dispatch thread or inside read-action only (see com.intellij.openapi.application.Application.runReadAction())

        (2):SSM整合中pom文件中的依赖:


        
            commons-fileupload
            commons-fileupload
            1.3.3
        
        
            com.mchange
            c3p0
            0.9.5.2
        
        
        
        
        
        
            log4j
            log4j
            1.2.17
        
        
        
            org.slf4j
            slf4j-log4j12
            1.7.24
            test
        

        
        
        
            org.springframework
            spring-aop
            5.2.1.RELEASE
        
        
        
            org.springframework
            spring-core
            5.2.1.RELEASE
        
        
        
            org.springframework
            spring-context
            5.2.1.RELEASE
        
        
        
            org.springframework
            spring-webmvc
            5.2.1.RELEASE
        
        
        
            org.springframework
            spring-web
            5.2.1.RELEASE
        
        
        
            org.springframework
            spring-beans
            5.2.1.RELEASE
        
        
        
            org.springframework
            spring-jdbc
            5.2.1.RELEASE
        
        
        
            org.springframework
            spring-aspects
            5.2.1.RELEASE
        
        
        
            org.springframework
            spring-expression
            5.2.1.RELEASE
        
        
        
            org.springframework
            spring-orm
            5.2.1.RELEASE
        
        
        
            org.springframework
            spring-tx
            5.2.1.RELEASE
        

        
            org.aspectj
            aspectjweaver
            1.9.4
        

        
        
        
            org.mybatis
            mybatis-spring
            2.0.2
        
        
        
        
            org.mybatis
            mybatis
            3.5.2
        

        
        
        
            mysql
            mysql-connector-java
            8.0.19
        
        
        
        
            com.alibaba
            druid
            1.1.10
        
        
        
            com.fasterxml.jackson.core
            jackson-databind
            2.9.9
        
        
        
            com.fasterxml.jackson.core
            jackson-core
            2.9.9
        
        
        
            com.fasterxml.jackson.core
            jackson-annotations
            2.9.9
        
        
        
            org.projectlombok
            lombok
            1.18.10
            provided
        
        
        
            junit
            junit
            4.12
            test
        
        
        
            org.hamcrest
            hamcrest-core
            1.3
            test
        
        
        
            javax.servlet
            servlet-api
            2.5
        
        
            javax.servlet.jsp
            jsp-api
            2.2
        
        
            javax.servlet
            jstl
            1.2
        
    


    

    
    
        
            
                src/main/resources
                
                    ***.xml
                
                true
            
            
                src/main/java
                
                    ***.xml
                
                true
            
        
    
2.mybatis的配置文件

        (1):mybatis配置文件的命名:mybatis-config.xml(推荐)

        (2):mybatis-config:配置文件内容




    

       
    
        
    

    
        
    

3.Spring的配置文件

        为便于理解将spring配置文件拆来来写:

        

         拆开后记得将配置文件合起来:

        

         具体配置如下:

        (1)applicationContext.xml:将spring配置文件整合




    
    
    

         (2)spring-dao.xml:配置数据库文件以及创建出SqlSessionFactory对象

        数据库文件:database.properties

        对应的mysql版本为8.0以上:

jdbc.driver=com.mysql.cj.jdbc.Driver
#时区配置 &serverTimezone=Asia/Shanghai
jdbc.url=jdbc:mysql://localhost:3306/ssmbuild?useSSL=true&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
jdbc.username=root
jdbc.password=123456



    
    
    
    
        
        
        
        
    

    
    
        
        
        
        
        
    

    
      
      
  

        (3)spring-service.xml:service层主要用于实现事务的 *** 作




    
    
    
    
        
    
    
    

        (4)spring-mvc:见SpringMVC配置文件

4.SpringMVC配置文件

        (1)生成web项目:

        

         (2)web.xml配置文件:

        着重注意:classpath:只能找到web.xml的上下文路径,直接配置spring-mvc并不能找到spring-mvc.xml文件,因此需要配置成spring的总文件applicationContext.xml。

 classpath:applicationContext.xml



    
    
        springmvc
        org.springframework.web.servlet.DispatcherServlet
        
            contextConfigLocation
            classpath:applicationContext.xml
        
        1
    
    
        springmvc
        /
    
    
    
        encodingFilter
        org.springframework.web.filter.CharacterEncodingFilter
        
            encoding
            utf-8
        
    
    
        encodingFilter
        /*
    
    
        15
    

         (3)spring-mvc.xml配置文件





    
    
    
    
    
    
    
    
    
    
    
          
          
          
          
    

5.SSM总体框架结构

        

 

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5680934.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存