Spring-SpringMvc-mybatis整合_笔记

applicationContext-mybatis.xml

Mybatis操作数据库的核心类是sqlSession,与Spring整合之后用的是
sqlSessionTemplate这个类。
不过还是以下面的mapper接口为主。







    
    
    
    
    





    




    
    
    
    
    






    


spring-servlet.xml





        
        
        


       
       
       

        
        
            
            
        


        
        
            
                
                    error   
                
            
        

        
        

        
        
            
           

jdbc.properties

driverClassName=com.mysql.jdbc.Driver
url=jdbc:mysql://127.0.0.1:3306/testdb?useUnicode=true&characterEncoding=UTF-8
username=root
password=wjb

log4j.properties

log4j.rootLogger=DEBUG,CONSOLE,file
#log4j.rootLogger=ERROR,ROLLING_FILE
log4j.logger.cn.jbit.dao=debug
log4j.logger.com.ibatis=debug 
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=debug 
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=debug 
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=debug 
log4j.logger.java.sql.Connection=debug 
log4j.logger.java.sql.Statement=debug 
log4j.logger.java.sql.PreparedStatement=debug 
log4j.logger.java.sql.ResultSet=debug 
log4j.logger.org.tuckey.web.filters.urlrewrite.UrlRewriteFilter=debug
######################################################################################
# Console Appender  \u65e5\u5fd7\u5728\u63a7\u5236\u8f93\u51fa\u914d\u7f6e
######################################################################################
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.Threshold=error
log4j.appender.CONSOLE.Target=System.out
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern= [%p] %d %c - %m%n
######################################################################################
# DailyRolling File  \u6bcf\u5929\u4ea7\u751f\u4e00\u4e2a\u65e5\u5fd7\u6587\u4ef6\uff0c\u6587\u4ef6\u540d\u683c\u5f0f:log2009-09-11
######################################################################################
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.DatePattern=yyyy-MM-dd
log4j.appender.file.File=log.log
log4j.appender.file.Append=true
log4j.appender.file.Threshold=error
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-M-d HH:mm:ss}%x[%5p](%F:%L) %m%n
log4j.logger.com.opensymphony.xwork2=error  

web.xml



  SMVCMybatis
  
  
    contextConfigLocation
    classpath:application-*.xml
  
  
  
    encodingFilter
    org.springframework.web.filter.CharacterEncodingFilter
    
        encoding
        UTF8
    
    
        forceEncoding
        true
    
  
  
    encodingFilter
    /*
  
  
  
  
    spring
    org.springframework.web.servlet.DispatcherServlet
    
        contextConfigLocation
        classpath:spring-servlet.xml
    
  
  
    spring
    /
  
    
        spring
        org.springframework.web.servlet.DispatcherServlet
        
            contextConfigLocation
            classpath:spring-servlet.xml
        
    
    
        spring
        /
    
  
  
    org.springframework.web.context.ContextLoaderListener
  
  
  
    log4jConfigLocation
    classpath:log4j.properties
  
  
  
    org.springframework.web.util.Log4jConfigListener
  
  
  
  
    index.jsp
  

spring的注解:

的目的是加载资源文件,通过注解@importResource("classpath:/com/jdbc.properties")也能实现。

你可能感兴趣的:(Spring-SpringMvc-mybatis整合_笔记)