pom.xm 文件添加依赖
pom.xml 文件如下:
4.0.0
com.bohua
ceshi
1.0-SNAPSHOT
war
ceshi Maven Webapp
http://www.example.com
UTF-8
1.7
1.7
4.3.5.RELEASE
org.springframework
spring-webmvc
${spring.version}
org.springframework
spring-tx
${spring.version}
org.springframework
spring-jdbc
${spring.version}
log4j
log4j
1.2.17
org.mybatis
mybatis
3.2.6
org.mybatis
mybatis-spring
1.3.2
com.github.pagehelper
pagehelper
3.2.3
mysql
mysql-connector-java
5.1.38
commons-fileupload
commons-fileupload
1.3.2
org.hibernate.validator
hibernate-validator
6.0.9.Final
com.alibaba
fastjson
1.2.44
jstl
jstl
1.2
javax.servlet
servlet-api
2.5
com.alibaba
druid
1.1.9
org.projectlombok
lombok
1.16.12
cn.hutool
hutool-all
4.1.1
org.mybatis.generator
mybatis-generator-core
1.3.2
junit
junit
4.11
test
ceshi
maven-clean-plugin
3.0.0
maven-resources-plugin
3.0.2
maven-compiler-plugin
3.7.0
maven-surefire-plugin
2.20.1
maven-war-plugin
3.2.0
maven-install-plugin
2.5.2
maven-deploy-plugin
2.8.2
org.mybatis.generator
mybatis-generator-maven-plugin
1.3.2
src/main/resources/generatorConfig.xml
true
true
Generate MyBatis Artifacts
generate
org.mybatis.generator
mybatis-generator-core
1.3.2
完成之后写配置文件
applicationContext.xml 如下:
applicationContext-mybatis.xml 如下:
classpath:database.properties
classpath:com/bohua/dao/**/*.xml
database.properties 如下:
jdbc.url=jdbc:mysql://127.0.0.1:3306/cesh?useUnicode=true&characterEncoding=utf-8
jdbc.username=root
jdbc.password=root
jdbc.driver=com.mysql.jdbc.Driver
log4j.properties 如下:
### 设置###
log4j.rootLogger = info,stdout,D,E
### 输出信息到控制抬 ###
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 = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
### 输出DEBUG 级别以上的日志到=E://logs/error.log ###
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.File = D://logs/log.log
log4j.appender.D.Append = true
log4j.appender.D.Threshold = DEBUG
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
### 输出ERROR 级别以上的日志到=E://logs/error.log ###
log4j.appender.E = org.apache.log4j.DailyRollingFileAppender
log4j.appender.E.File =D\://logs/error.log
log4j.appender.E.Append = true
log4j.appender.E.Threshold = ERROR
log4j.appender.E.layout = org.apache.log4j.PatternLayout
log4j.appender.E.layout.ConversionPattern =%-d{yyyy-MM-dd HH\:mm\:ss} [ %t\:%r ] - [ %p ] %m%n
mybatis-config.xml 如下:
spring-mvc.xml 如下:
WriteMapNullValue
WriteNullStringAsEmpty
编写实体类 ( 有条件的话可以自动生成 )
mapper接口 如下:
mapper.xml 如下:
service接口 如下:
service 实现接口 如下:
controller 控制类 如下:
登录 页面
然后运行 到此完毕!