SSM整合

引入依赖:



    4.0.0

    org.example
    ssm1
    1.0-SNAPSHOT
    war

    
        11
        11
        UTF-8
    
    

        
            com.github.pagehelper
            pagehelper
            5.1.11
        
        
            org.slf4j
            slf4j-api
            1.7.36
        
      
            ch.qos.logback
            logback-classic
            1.2.11
        
     
            org.springframework.data
            spring-data-commons
            2.3.9.RELEASE
        
        
            junit
            junit
            4.13.2
            test
        
        
            javax.servlet
            servlet-api
            2.5
        
        
            commons-fileupload
            commons-fileupload
            1.4
        
        
            com.fasterxml.jackson.core
            jackson-core
            2.13.4
        
        
            com.fasterxml.jackson.core
            jackson-databind
            2.13.4
        
        
            com.fasterxml.jackson.core
            jackson-annotations
            2.13.4
        
        
            org.springframework
            spring-webmvc
            5.2.18.RELEASE
        
        
            org.springframework
            spring-jdbc
            5.2.18.RELEASE
        
        
            org.aspectj
            aspectjweaver
            1.9.7
        
        
            mysql
            mysql-connector-java
            5.1.49
            runtime
        
        
            org.mybatis
            mybatis
            3.5.7
        
        
            org.mybatis
            mybatis-spring
            2.0.6
        
        
            com.alibaba
            druid
            1.2.8
        
        
            org.projectlombok
            lombok
            1.18.22
        
    

Spring-mvc.xml文件:



 

    

    
    
    
    
    

配置Spring的配置文件:




    
    
    
    
    




    
    
        
        
        
        
    

    
        
    
    
        
        
        
        
        
            

                
                    
                        

                            helperDialect=mysql
                        
                    
                
            
        
    
    
    
        
    

    

    
        
    

    
        

            
            
            
            
            
            
            
        
    

    
        
        
    

配置web.xml




    
    
        springmvc
        org.springframework.web.servlet.DispatcherServlet
        
            contextConfigLocation
            classpath:application.xml
        
        
        1
    
    
        springmvc
        /
    

    
    
        characterEncodingFilter
        org.springframework.web.filter.CharacterEncodingFilter
        
            encoding
            UTF-8
        
    

    
        characterEncodingFilter
        /
    

    
    
        hiddenHttpMethodFilter
        org.springframework.web.filter.HiddenHttpMethodFilter
    
    
        hiddenHttpMethodFilter
        /*
    

    
        druidWebStatFilter
        com.alibaba.druid.support.http.WebStatFilter
        
            exclusions
            *.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*
        
    
    
        druidWebStatFilter
        /*
    
    
        DruidStatView
        com.alibaba.druid.support.http.StatViewServlet
        
            loginAccountname
            jsoft
        
        
            loginpassword
            123456
        
    
    
        DruidStatView
        /druid/*
    

整合日志框架的依赖:

 
            org.slf4j
            slf4j-api
            1.7.36
        
      
            ch.qos.logback
            logback-classic
            1.2.11
        

整合日志框架的配置文件:

logback.xml



    
    
    
    
    
    
    
    
    
        
            ${log.pattern}
        
    
    
    
        
        ${log.filePath}/debug.log
        
        
            
            
                ${log.filePath}/debug/debug.%d{yyyy-MM-dd}.log.gz
            
            
            ${log.maxHistory}
        
        
            ${log.pattern}
        
        
            DEBUG
            ACCEPT
            DENY
        
    
    
    
        
        ${log.filePath}/info.log
        
            
            ${log.filePath}/info/info.%d{yyyy-MM-dd}.log.gz
            
            
            ${log.maxHistory}
        
        
            ${log.pattern}
        
        
            INFO
            ACCEPT
            DENY
        
    
    
    
        
        
    
    
    
        
    

    
    
        ${log.filePath}/sql_log/mybatis-sql.log
        
            ${log.filePath}/sql_log/mybatis-sql.log.%d{yyyy-MM-dd}
            
            30
        
        
            %thread|%d{yyyy-MM-dd HH:mm:ss.SSS}|%level|%logger{36}|%m%n
        
    
    
        
    

利用log对象来进行日志的打印输出。

SSM整合_第1张图片

或者使用注解:

SSM整合_第2张图片
SSM整合_第3张图片

分页插件: pageHelper

        
            com.github.pagehelper
            pagehelper
            5.0.0
        
SSM整合_第4张图片
SSM整合_第5张图片

controller层:

    @GetMapping("page")
    public PageInfo selectAll(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                                       @RequestParam(value = "pageSize",defaultValue = "2") Integer pageSize){
        return accountService.getPage(pageNum,pageSize);
    }

配置分页参数合理化,防止出现恶意输入,整合进mybatis:

    
        
            
        
    

你可能感兴趣的:(SSM框架,java,spring,boot,mybatis)