자바 mysql 주종 전환 실현 (두 번 째 부분)
22147 단어 자바mysql데이터 원본 전환DEVELOPMENT
--------------------------------
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
configuration
PUBLIC"-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
--------------------------------
spring-mvc.xml
text/html;charset=UTF-8
text/plain;charset=UTF-8
application/json;charset=UTF-8
--------------------------------
UpmsLogMapper.xml
mapper PUBLIC"-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
and${criterion.condition}
and${criterion.condition} #{criterion.value}
and${criterion.condition} #{criterion.value} and #{criterion.secondValue}
and${criterion.condition}
#{listItem}
delete 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
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Is Eclipse IDE dying?In 2014 the Eclipse IDE is the leading development environment for Java with a market share of approximately 65%. but ac...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.