依赖和插件配置管理
pom.xml:
UTF-8
UTF-8
1.8
1.1.6
4.5.5
1.5
1.3.2
3.5
5.3.4.Final
2.9.5
1.2
4.12
2.3
1.2.17
1.16.18
1.3.1
3.2.8
5.1.46
3.1.0
1.7.25
4.3.17.RELEASE
org.springframework
spring-test
${spring.version}
junit
junit
${junit.version}
org.springframework
spring-context
${spring.version}
org.springframework
spring-webmvc
${spring.version}
org.springframework
spring-aspects
${spring.version}
javax.servlet
javax.servlet-api
${servlet-api.version}
provided
javax.servlet
jstl
${jstl.version}
org.slf4j
slf4j-api
${slf4j.version}
org.slf4j
slf4j-log4j12
${slf4j.version}
org.slf4j
jcl-over-slf4j
${slf4j.version}
org.slf4j
jul-to-slf4j
${slf4j.version}
log4j
log4j
${log4j.version}
org.apache.commons
commons-lang3
${commons-lang3.version}
commons-fileupload
commons-fileupload
${commons-fileupload.version}
org.apache.commons
commons-email
${commons-email.version}
com.alibaba
druid
${alibaba-druid.version}
mysql
mysql-connector-java
${mysql.version}
org.mybatis
mybatis
${mybatis.version}
org.mybatis
mybatis-spring
${mybaits-spring.version}
org.springframework
spring-jdbc
${spring.version}
org.hibernate
hibernate-validator
${hibernate-validator.version}
com.fasterxml.jackson.core
jackson-core
${jackson.version}
com.fasterxml.jackson.core
jackson-databind
${jackson.version}
com.fasterxml.jackson.core
jackson-annotations
${jackson.version}
org.apache.httpcomponents
httpclient
${apache-httpclient.version}
org.apache.httpcomponents
fluent-hc
${apache-httpclient.version}
org.apache.httpcomponents
httpmime
${apache-httpclient.version}
com.google.code.kaptcha
kaptcha
${kaptcha.version}
org.projectlombok
lombok
${lombok.version}
nexus-releases
Nexus Release Repository
http://192.168.0.105:8081/repository/maven-releases/
nexus-snapshots
Nexus Snapshot Repository
http://192.168.0.105:8081/repository/maven-snapshots/
nexus
Nexus Repository
http://192.168.0.105:8081/repository/maven-public/
true
true
nexus
Nexus Plugin Repository
http://192.168.0.105:8081/repository/maven-public/
true
true
org.apache.maven.plugins
maven-compiler-plugin
3.7.0
${java.version}
${project.build.sourceEncoding}
true
src/main/java
**/*.java
src/main/resources
log4j配置
log4j.properties:
log4j.rootLogger=INFO, console, file
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d %p [%c] - %m%n
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.File=logs/log.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.A3.MaxFileSize=1024KB
log4j.appender.A3.MaxBackupIndex=10
log4j.appender.file.layout.ConversionPattern=%d %p [%c] - %m%n
日志配置相关说明:
-
log4j.rootLogger
:根日志,配置了日志级别为 INFO,预定义了名称为 console、file 两种附加器 -
log4j.appender.console
:console 附加器,日志输出位置在控制台 -
log4j.appender.console.layout
:console 附加器,采用匹配器布局模式 -
log4j.appender.console.layout.ConversionPattern
:console 附加器,日志输出格式为:日期 日志级别 [类名] - 消息换行符 -
log4j.appender.file
:file 附加器,每天产生一个日志文件 -
log4j.appender.file.File
:file 附加器,日志文件输出位置logs/log.log
-
log4j.appender.file.layout
:file 附加器,采用匹配器布局模式 -
log4j.appender.A3.MaxFileSize
:日志文件最大值 -
log4j.appender.A3.MaxBackupIndex
:最多纪录文件数 -
log4j.appender.file.layout.ConversionPattern
:file 附加器,日志输出格式为:日期 日志级别 [类名] - 消息换行符
Mybatis配置
mybatis-config.xml:
配置Spring相关
Spring基础配置
spring-context:
整合数据库连接池Druid
spring-context-druid.xml:
jdbc.properties:
# JDBC
# Mysql8.x 使用com.mysql.cj.jdbc.Driver
jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.connectionURL=jdbc:mysql://localhost:3306/myshop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
jdbc.username=root
jdbc.password=123456
# JDBC Pool
jdbc.pool.init=1
jdbc.pool.minIdle=3
jdbc.pool.maxActive=20
# JDBC Test
jdbc.testSql=SELECT 'x' FROM DUAL
整合Mybatis
spring-context-mybatis.xml:
配置SpringMVC
spring-mvc.xml:
web应用入口配置
web.xml:
contextConfigLocation
classpath:spring-context*.xml
org.springframework.web.context.ContextLoaderListener
encodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
forceEncoding
true
encodingFilter
/*
springServlet
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath*:/spring-mvc*.xml
1
springServlet
/
DruidStatView
com.alibaba.druid.support.http.StatViewServlet
DruidStatView
/druid/*