搭建ssm代码通用框架

搭建ssm代码通用框架,第1张

搭建ssm代码通用框架

1.maven的pom文件配置



    4.0.0

    com.xxx.xxx
    xxx
    1.0-SNAPSHOT


    war  
    
        5.2.13.RELEASE
        3.5.6
        1.3.3
        5.1.10
        8.0.23
        1.2.3
        4.0.1
        2.9.6
        1.2.17
        4.12
    

     
        
            org.springframework
            spring-webmvc
            ${spring.version}
        
        
            org.springframework
            spring-tx
            ${spring.version}
        
        
            org.springframework
            spring-jdbc
            ${spring.version}
        
        
            org.springframework
            spring-aspects
            ${spring.version}
        
        
            commons-fileupload
            commons-fileupload
            1.3.1
        
        
        
            org.mybatis
            mybatis
            ${mybatis.version}
        
        
            org.mybatis
            mybatis-spring
            ${mybatis.spring.version}
         
        
            com.github.pagehelper
            pagehelper
            ${pagehelper.version}
         
        
            mysql
            mysql-connector-java
            ${mysql.version}
         
        
            com.alibaba
            druid
            ${druid.version}
         
        
            javax.servlet
            javax.servlet-api
            ${servlet-api.version}
            provided
         
        
            com.fasterxml.jackson.core
            jackson-databind
            ${jackson.version}
         
        
            log4j
            log4j
            ${log4j.version}
         
        
            junit
            junit
            ${junit.version}
            test
        
        
            org.springframework
            spring-test
            ${spring.version}
         
        
            javax.annotation
            javax.annotation-api
            1.3.2
        
     
    
        
            
                src/main/java
                
                    ***.xml
                
                false
            
        
         
            
                org.apache.maven.plugins
                maven-compiler-plugin
                
                    1.8
                    1.8
                    UTF-8
                
             
            
                org.apache.tomcat.maven
                tomcat7-maven-plugin
                2.2
                 
                    8088 
                    /
                    UTF-8
                
             
            
                org.mybatis.generator
                mybatis-generator-maven-plugin
                1.3.5
                 
                    src/main/resources/generatorConfig.xml
                    true
                
                






                    
                        org.mybatis.generator
                        mybatis-generator-core
                        1.3.5
                    
                
            
        
    



2.容器xml的配置
spring.xml配置,即上下文context容器bean的配置




    
     
    
     
        
        
        
        
    
     
        
         
         
         
        
            
                
                    
                        reasonable=true
                    
                
            
        
      
    
        
        
     
    
    
        
    


springMVC的容器配置



      
    
     
    
        
        
     
    
    
    
    
    
    
     
    
    
    

web.inf的配置,设置好容器参数



    
        /pages/login.html
     

     
        contextConfigLocation
        classpath*:spring.xml
    


    
        org.springframework.web.context.ContextLoaderListener
     
    
        dispatcherServlet
        org.springframework.web.servlet.DispatcherServlet
         
        
            contextConfigLocation
            classpath*:springmvc.xml
         
        1
     
    
        dispatcherServlet
        *.do
     

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

    
        characterEncodingFilter
        org.springframework.web.filter.CharacterEncodingFilter 
        





            encoding
            UTF-8
         
        
            forceRequestEncoding
            true
         
        
            forceResponseEncoding
            true
        
    
    
        characterEncodingFilter
        /*
    

3.mabatis的反向生成
配置mybatis的xml配置

 

    
        
     
    

配置log4j

log4j.rootLogger=DEBUG,stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

配置数据库

jdbc.driver=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://127.0.0.1:3306/myssm_kkb? useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT
jdbc.username=root
jdbc.password=xxxx

配置mybatisgenerater.xml

  
 
    
    
        
        
        
            
            
         
         
        
            
         
        
            
         
         
          
        
            
        
        
            
        
        
            
        
        
            
        
        



            
        
        
            
        
    

生成pojo,mapper

4.在上下文spring.xml容器配置中加注service扫描路径,service加注@Service注解,controller层加注@Controller,自编写配置类加注@Component。前端返回json格式,controller还需加注@ResponseBody,@RequestMapping映射地址等。


5.设置事务

	
    
        
    

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

原文地址: http://outofmemory.cn/zaji/5693612.html

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

发表评论

登录后才能评论

评论列表(0条)

保存