Resources部分

 

--------------------------------

applicationContext-datasource.xml

 



 
   
   
   
   
 
   
   
   
   
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
        
       
       
       
       
   
 
    
   
       
       
       
       
       
       
        
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
   
 
   
   
       
           
                
                
                
           
       
       
   
 
 
   
   
       
       
       
       
       
       
       
   
 
   
   
   
       
       
   
 
   
   
       
   
 
   
   
 

 

--------------------------------

applicationContext-listener.xml

 



 
   
   
       
   
 
    
   
 
   
   
 

 

--------------------------------

jdbc.properties

 

#DB
dataSource.master.driverClassName=com.mysql.jdbc.Driver
dataSource.master.url=jdbc\:mysql\://127.0.0.1\:3306/zheng?useUnicode\=true&characterEncoding\=utf-8&autoReconnect\=true
dataSource.master.username = root
dataSource.master.password = root
 
dataSource.slave.driverClassName=com.mysql.jdbc.Driver
dataSource.slave.url=jdbc\:mysql\://127.0.0.1\:3306/zheng?useUnicode\=true&characterEncoding\=utf-8&autoReconnect\=true
dataSource.slave.username = root
dataSource.slave.password = root
 
dataSource.initialSize  =  2
dataSource.maxActive = 30
dataSource.maxIdle = 2
dataSource.minIdle = 2
dataSource.maxOpenPreparedStatements = 150
dataSource.validationQuery = SELECT 1 FROMDUAL
dataSource.testWhileIdle = true
dataSource.testOnBorrow = false
dataSource.testOnReturn = false
#\u914d\u7f6e\u95f4\u9694\u591a\u4e45\u624d\u8fdb\u884c\u4e00\u6b21\u68c0\u6d4b\uff0c\u68c0\u6d4b\u9700\u8981\u5173\u95ed\u7684\u7a7a\u95f2\u8fde\u63a5\uff0c\u5355\u4f4d\u662f\u6beb\u79d2
dataSource.timeBetweenEvictionRunsMillis =60000
#\u914d\u7f6e\u4e00\u4e2a\u8fde\u63a5\u5728\u6c60\u4e2d\u6700\u5c0f\u751f\u5b58\u7684\u65f6\u95f4\uff0c\u5355\u4f4d\u662f\u6beb\u79d2
dataSource.minEvictableIdleTimeMillis =300000
# \u6253\u5f00PSCache\uff0c\u5e76\u4e14\u6307\u5b9a\u6bcf\u4e2a\u8fde\u63a5\u4e0aPSCache\u7684\u5927\u5c0f
dataSource.poolPreparedStatements = true
dataSource.maxPoolPreparedStatementPerConnectionSize= 20
#\u914d\u7f6e\u76d1\u63a7\u7edf\u8ba1\u62e6\u622a\u7684filter
dataSource.filters = stat

 

--------------------------------

log4j.properties

 

#off/fatal/error/warn/info/debug/all
log4j.debug=false
log4j.rootLogger=info,stdout,log,errorlog
 
# Console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target = System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d[%t] %-5p [%c] - %m%n
 
### Log ###
log4j.appender.log =org.apache.log4j.DailyRollingFileAppender
log4j.appender.log.File =../logs/zheng-upms5-server.log
log4j.appender.log.Append = true
log4j.appender.log.Threshold = DEBUG
log4j.appender.log.DatePattern='.'yyyy-MM-dd
log4j.appender.log.layout =org.apache.log4j.PatternLayout
log4j.appender.log.layout.ConversionPattern= %-d{yyyy-MM-dd HH:mm:ss} [ %p ] [ %C{1}.java :%L(%M)]  %m%n
 
### Error ###
log4j.appender.errorlog =org.apache.log4j.DailyRollingFileAppender
log4j.appender.errorlog.File =../logs/zheng-upms5-server.error.log
log4j.appender.errorlog.Append = true
log4j.appender.errorlog.Threshold = ERROR
log4j.appender.errorlog.DatePattern='.'yyyy-MM-dd
log4j.appender.errorlog.layout =org.apache.log4j.PatternLayout
log4j.appender.errorlog.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [ %p ] [ %C{1}.java :%L(%M)] %m%n
 
#Spring logging configuration
log4j.category.org.springframework = warn
 
#Druid logging configuration
log4j.logger.druid.sql=warn,stdout,log,errorlog
log4j.logger.druid.sql.DataSource=warn,stdout,log,errorlog
log4j.logger.druid.sql.Connection=warn,stdout,log,errorlog
log4j.logger.druid.sql.Statement=warn,stdout,log,errorlog
log4j.logger.druid.sql.ResultSet=warn,stdout,log,errorlog
 
# MyBatis logging configuration
log4j.logger.com.vivebest.dao=debug

 

--------------------------------

mybatis-config.xml

 



 

 
         
         
                   
                   
                   
                   
                   
                   
                   
                   
                   
         
 
         
         
                   
                   
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
                            
                   
         
 

 

--------------------------------

spring-mvc.xml

 



 
   
 
   
   
   
 
   
   
   
 
   
   
       
           
                
                    
                        
                           text/html;charset=UTF-8
                           text/plain;charset=UTF-8
                           application/json;charset=UTF-8
                        
                    
                
           
       
   
   
   
   
       
       
    

 

--------------------------------

UpmsLogMapper.xml

 




 
   
       
           
                
                    
                        
                            
                                
                                    and${criterion.condition}
                                
                                
                                    and${criterion.condition} #{criterion.value}
                                
                                
                                    and${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                
                                
                                    and${criterion.condition}
                                    
                                       #{listItem}
                                    
                                
                            
                        
                    
                
           
       
   
 
   
     select count(*) from upms_log
   
   
       delete from upms_log
       
           
       
   
 
   
       select count(*) from upms_log
   
 
   
       delete from upms_log
       
           
       
   
 
   

 

--------------------------------

WEB部分

 

Web.xml

 



   zheng-upms5-server
 
   
   
       org.springframework.web.context.ContextLoaderListener
   
 
   
   
       contextConfigLocation
       classpath:applicationContext*.xml
   
 
   
   
       log4jConfigLocation
       classpath:log4j.properties
   
 
   
   
       springMVC
       org.springframework.web.servlet.DispatcherServlet
       
           contextConfigLocation
           classpath:spring-mvc.xml
       
       1
   
 
   
   
       springMVC
        /
   
 

 

Index.jsp

 



Hello World!

 

POM.XML部分

 


   4.0.0
   com.zheng
   zheng-upms5-server
   war
   zheng-upms5-server Maven Webapp
   http://maven.apache.org
   1.0.0
   
       UTF-8
 
       1.7
       1.7
       1.7
 
       4.3.7.RELEASE
       4.1.3.RELEASE
 
       3.4.2
       1.3.1
       5.0.1
       1.3.5
       1.0.0
       2.10.0
   
 
   
       
           junit
           junit
           4.12
           test
       
       
       
           org.springframework
           spring-context-support
           ${spring.version}
       
       
           org.springframework
           spring-webmvc
            ${spring.version}
       
       
           org.springframework
           spring-jdbc
           ${spring.version}
       
       
           org.springframework
           spring-test
           ${spring.version}
       
       
       
           org.mybatis
           mybatis
           ${mybatis.version}
       
       
           org.mybatis
           mybatis-spring
           ${mybatis-spring.version}
       
       
           com.github.pagehelper
           pagehelper
            ${mybatis-pagehelper.version}
       
       
           org.mybatis.generator
           mybatis-generator-core
           ${mybatis-generator.version}
       
       
       
           net.sf.ehcache
           ehcache
           ${ehcache.version}
       
       
           org.mybatis
           mybatis-ehcache
           ${mybatis-ehcache.version}
       
       
       
           mysql
           mysql-connector-java
           5.1.34
           runtime
       
       
           com.alibaba
           druid
           1.0.14
       
       
       
           org.slf4j
           slf4j-api
           1.7.12
       
       
           org.slf4j
           slf4j-log4j12
           1.7.12
       
       
       
            commons-beanutils
           commons-beanutils
           1.9.3
       
       
           commons-lang
           commons-lang
           2.6
       
       
           commons-codec
           commons-codec
           1.10
       
       
           org.apache.commons
           commons-compress
           1.12
       
       
       
           net.sf.json-lib
           json-lib
           2.4
           jdk15
       
       
           com.alibaba
           fastjson
           1.2.28
       
       
           com.fasterxml.jackson.core
           jackson-core
           2.6.5
       
       
           com.fasterxml.jackson.core
           jackson-databind
           2.6.5
       
       
           com.fasterxml.jackson.core
           jackson-annotations
           2.6.5
       
       
       
           javax.servlet
           servlet-api
           2.5
           provided
       
       
           javax.servlet
           jstl
           1.2
       
   
 
   
       zheng-upms5-server
       
           
               org.apache.maven.plugins
                maven-surefire-plugin
               2.18.1
                
                   true
                   true
                
           
       
   
 

 

3、测试方法

 
http://localhost:1111/customer/queryLog                       
通过从库处理
 
http://localhost:1111/customer/queryLogB
通过主库处理
 
http://localhost:1111/customer/deleteLog/1
通过主库处理
 
http://localhost:1111/customer/deleteLogB/2
通过主库处理