mybatis与spring的集成

作为一名合格的程序员,我直接上代码说明问题

  • 项目结构
    mybatis与spring的集成_第1张图片
  • web.xml文件




  
    spring3mvc
    org.springframework.web.servlet.DispatcherServlet
    
      contextConfigLocation
      classpath*:/applicationContext.xml
    
    1
  
  
    spring3mvc
    /*
  

  
    encodingFilter
    org.springframework.web.filter.CharacterEncodingFilter
    
      encoding
      UTF-8
    
    
      forceEncoding
      true
    
  
  
    encodingFilter
    /*
  



  • applicationContext.xml(spring文件)



    Spring公共配置

    
    

    
    

    
        
            
                classpath*:conf/conf.properties
            
        
        
            UTF-8
        
    
    
        
    





  • mvc.xml(springmvc文件)



    
        
            
                application/json;charset=UTF-8
            
        
    

    
    
        
        
            
                
            
            
        
    

    
    
    
    
    
    

    
        
        
        
        
            
                atom=application/atom+xml
                html=text/html
                json=application/json
                *=*/*
            
        
    

    
    
        
        
        
    

  • database.xml(数据库文件和mybatis文件)



    
    
        
        
        
        
    

    
    
        
    

    
    
        
        
        
    

    
    
        
        
    

    
    


  • pom依赖



  4.0.0

  com.jd
  jd-test
  1.0-SNAPSHOT
  war

  jd-test Maven Webapp
  
  http://www.example.com

  
    UTF-8
    UTF-8
    1.8
    
    1.2.16
    1.7.6
    4.2.5.RELEASE
    4.12
    1.4
    1.8
    1.8

  

  
    
    
      com.jd.common
      sso-uim-spring
      1.0.5-SNAPSHOT
    
    
      junit
      junit
      ${junit.version}
      test
    
    
    
      org.springframework
      spring-core
      ${spring.version}
    
    
      org.springframework
      spring-context
      ${spring.version}
    
    
      org.springframework
      spring-context-support
      ${spring.version}
    
    
      org.springframework
      spring-beans
      ${spring.version}
    
    
      org.springframework
      spring-test
      ${spring.version}
      test
    
    
      org.springframework
      spring-web
      ${spring.version}
    
    
      org.springframework
      spring-orm
      ${spring.version}
    
    
      org.springframework
      spring-webmvc
      ${spring.version}
    

    
    
      com.fasterxml.jackson.core
      jackson-core
      2.5.2
    
    
      com.fasterxml.jackson.core
      jackson-databind
      2.5.2
    

    
    
      org.mybatis
      mybatis
      3.2.3
    
    
      org.mybatis
      mybatis-spring
      1.2.1
    
    
      mysql
      mysql-connector-java
      5.1.40
      runtime
    
    
      commons-dbcp
      commons-dbcp
      ${commons.bdcp.version}
    
    
      commons-dbutils
      commons-dbutils
      1.6
    


    
    
      org.slf4j
      slf4j-log4j12
      ${slf4j.version}
    

    
    
      commons-io
      commons-io
      1.3.2
    
    
      commons-fileupload
      commons-fileupload
      1.3.1
    
    
    
      com.squareup.okhttp3
      okhttp
      3.11.0
    


    
      javax.servlet
      javax.servlet-api
      3.1.0
      provided
    
    
    
      com.belerweb
      pinyin4j
      2.5.0
    
    
    
      com.jcraft
      jsch
      0.1.55
    
    
      joda-time
      joda-time
      2.2
    

    
      commons-codec
      commons-codec
      1.6
    

    
      com.alibaba
      fastjson
      1.1.38
    

    
      com.google.guava
      guava
      14.0
    
    
    
      org.codehaus.groovy
      groovy-all
      3.0.0-alpha-3
      pom
    


    
    
      org.activiti
      activiti-spring
      5.18.0
    
    
      org.activiti
      activiti-engine
      5.18.0
      
        
          slf4j-api
          org.slf4j
        
        
          spring-beans
          org.springframework
        
        
          jackson-core-asl
          org.codehaus.jackson
        
        
          commons-lang3
          org.apache.commons
        
        
          commons-lang3
          org.apache.commons
        
      
    

    
    
      org.projectlombok
      lombok
      1.18.4
      provided
    
    
    
      org.apache.kafka
      kafka-clients
      2.1.0
    
    
    
      org.springframework.integration
      spring-integration-kafka
      3.1.0.RELEASE
    
    
      
      
      
      
      
    
    
      org.apache.httpcomponents
      httpclient
      4.4.1
    

    
      io.netty
      netty-all
      4.1.6.Final
    
  
  
    lab-flow-web

    
      
        org.apache.maven.plugins
        maven-clean-plugin
        3.1.0
        
          
          false
          
            
              
              ${basedir}/src/cccc
              
              
                *.tmp
                *.log
              
              
              
                *.txt
              
              
              false
            
          
        
      
      
        
        
        
      
      
        
        org.eclipse.jetty
        jetty-maven-plugin
        9.4.12.v20180830
        
          5
          
            /
          
        
      
      
      
        
        org.apache.maven.plugins
        maven-compiler-plugin
        3.1
        
          
          1.8 
          1.8 
          UTF-8
        
      
      
        org.apache.maven.plugins
        maven-war-plugin
        2.1.1
        
          
          
          
          
            
              src/main/webapp
              true
            
          
          
            
              
              
            
          
        
      
    
  



代码路径:

https://github.com/takeMeFlyToAir/springMybatis

  • 项目里还包括了其他的配置,kafka消息队列,sftp上传文件,文件压缩,netty,工作流activiti等等

你可能感兴趣的:(spring,mybatis)