在以往的项目中我们使用的是单结构工程
在小程序这个项目中我们会使用maven搭建分层的聚合工程
一个imooc-video工程下,有很多子工程common、mapper、api、pojo等子工程。
一般分为common层其他工程都可以调用,pojo层数据库的实体类,mapper层数据库的映射java文件,service层,这些分层的工程之前可以互相调用。
我们可以先建一个这样的目录结构mybatis-generatorconfig 是数据库mapper的生成工程,后面会把代码放出来。
<
4.0.0
com.imooc
imooc-videos-dev
0.0.1-SNAPSHOT
pom
微信小程序-短视频实战
微信小程序实战课程:
小程序
maven
springmvc
springboot
mybatis
mybatis-pagehelper
redis
ffmpeg
druid
mariadb/mysql
zookeeper音频操作
org.springframework.boot
spring-boot-starter-parent
1.5.12.RELEASE
UTF-8
UTF-8
1.8
org.springframework.boot
spring-boot-maven-plugin
imooc-videos-dev-common
imooc-videos-dev-pojo
imooc-videos-dev-mapper
imooc-videos-dev-service
imooc-videos-dev-mini-api
4.0.0
com.imooc
imooc-videos-dev
0.0.1-SNAPSHOT
imooc-videos-dev-common
UTF-8
org.springframework.boot
spring-boot-starter
org.springframework.boot
spring-boot-starter-logging
org.springframework.boot
spring-boot-starter-log4j
1.3.8.RELEASE
org.springframework.boot
spring-boot-starter-aop
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-configuration-processor
true
org.springframework.boot
spring-boot-starter-thymeleaf
com.alibaba
druid
1.1.0
com.alibaba
druid-spring-boot-starter
1.1.0
mysql
mysql-connector-java
5.1.41
org.mybatis.spring.boot
mybatis-spring-boot-starter
1.3.1
tk.mybatis
mapper-spring-boot-starter
1.2.4
com.github.pagehelper
pagehelper-spring-boot-starter
1.2.3
commons-codec
commons-codec
1.11
org.apache.commons
commons-lang3
3.4
org.apache.commons
commons-io
1.3.2
io.springfox
springfox-swagger2
2.4.0
io.springfox
springfox-swagger-ui
2.4.0
org.springframework.boot
spring-boot-starter-data-redis
redis.clients
jedis
2.9.0
org.springframework.data
spring-data-redis
1.8.7.RELEASE
org.apache.curator
curator-framework
4.0.0
org.apache.zookeeper
zookeeper
3.4.11
org.apache.curator
curator-recipes
4.0.0
org.springframework.boot
spring-boot-maven-plugin
4.0.0
com.imooc
imooc-videos-dev
0.0.1-SNAPSHOT
imooc-videos-dev-pojo
com.imooc
imooc-videos-dev-common
0.0.1-SNAPSHOT
4.0.0
com.imooc
imooc-videos-dev
0.0.1-SNAPSHOT
imooc-videos-dev-mapper
com.imooc
imooc-videos-dev-pojo
0.0.1-SNAPSHOT
4.0.0
com.imooc
imooc-videos-dev
0.0.1-SNAPSHOT
imooc-videos-dev-service
UTF-8
UTF-8
1.8
com.imooc
imooc-videos-dev-mapper
0.0.1-SNAPSHOT
1、pom配置:
4.0.0
com.imooc
imooc-videos-dev
0.0.1-SNAPSHOT
imooc-videos-dev-mini-api
com.imooc
imooc-videos-dev-service
0.0.1-SNAPSHOT
2、application.properties配置
############################################################
#
# REDIS \u914d\u7f6e
#
############################################################
# Redis\u6570\u636e\u5e93\u7d22\u5f15\uff08\u9ed8\u8ba4\u4e3a0\uff09
spring.redis.database=1
# Redis\u670d\u52a1\u5668\u5730\u5740
spring.redis.host=192.168.1.209
# Redis\u670d\u52a1\u5668\u8fde\u63a5\u7aef\u53e3
spring.redis.port=6379
# Redis\u670d\u52a1\u5668\u8fde\u63a5\u5bc6\u7801\uff08\u9ed8\u8ba4\u4e3a\u7a7a\uff09
spring.redis.password=imooc
# \u8fde\u63a5\u6c60\u6700\u5927\u8fde\u63a5\u6570\uff08\u4f7f\u7528\u8d1f\u503c\u8868\u793a\u6ca1\u6709\u9650\u5236\uff09
spring.redis.pool.max-active=1000
# \u8fde\u63a5\u6c60\u6700\u5927\u963b\u585e\u7b49\u5f85\u65f6\u95f4\uff08\u4f7f\u7528\u8d1f\u503c\u8868\u793a\u6ca1\u6709\u9650\u5236\uff09
spring.redis.pool.max-wait=-1
# \u8fde\u63a5\u6c60\u4e2d\u7684\u6700\u5927\u7a7a\u95f2\u8fde\u63a5
spring.redis.pool.max-idle=10
# \u8fde\u63a5\u6c60\u4e2d\u7684\u6700\u5c0f\u7a7a\u95f2\u8fde\u63a5
spring.redis.pool.min-idle=2
# \u8fde\u63a5\u8d85\u65f6\u65f6\u95f4\uff08\u6beb\u79d2\uff09
spring.redis.timeout=0
############################################################
#
# 配置数据源相关 使用阿里巴巴的druid 数据源
#
############################################################
spring.datasource.url=jdbc:mysql://localhost:3306/imooc-video-dev
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.druid.initial-size=1
spring.datasource.druid.min-idle=1
spring.datasource.druid.max-active=20
spring.datasource.druid.test-on-borrow=true
spring.datasource.druid.stat-view-servlet.allow=true
############################################################
#
# mybatis 配置
#
############################################################
# mybatis 配置
mybatis.type-aliases-package=com.imooc.pojo # 数据库字段的实体类
mybatis.mapper-locations=classpath:mapper/*.xml # mapper的xml文件
# 通用Mapper 配置
mapper.mappers=com.imooc.utils.MyMapper
mapper.not-empty=false
mapper.identity=MYSQL
# 分页插件配置
pagehelper.helperDialect=mysql
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql
# 文件上传配置
spring.http.multipart.maxFileSize=100Mb
spring.http.multipart.maxRequestSize=1000Mb
############################################################
#
# Server 端口配置
#
############################################################
# \u914d\u7f6eapi\u7aef\u53e3\u53f7
server.port=8081
############################################################
# Server - tomcat 编码配置
############################################################
# tomcat\u7684URI\u7f16\u7801
server.tomcat.uri-encoding=UTF-8
3、log4j.properties
log4j.rootLogger=INFO,console,dailyFile
# TODO \u53d1\u5e03\u5230\u963f\u91cc\u4e91\u8bb0\u5f97\u6dfb\u52a0\uff0c\u53e6\u5916\u63a7\u5236\u53f0\u4e0d\u8f93\u51fa(\u53ea\u8f93\u51fawarn\u6216\u8005error\u4fe1\u606f)
#INFO,console,dailyFile
#log4j.logger.org.mybatis = DEBUG
log4j.logger.com.imooc.mapper=INFO
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.encoding=UTF-8
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} [%t] [%l] - [%p] %m%n
# \u5b9a\u671f\u6eda\u52a8\u65e5\u5fd7\u6587\u4ef6\uff0c\u6bcf\u5929\u90fd\u4f1a\u751f\u6210\u65e5\u5fd7
log4j.appender.dailyFile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.dailyFile.encoding=UTF-8
log4j.appender.dailyFile.Threshold=INFO
# TODO \u672c\u5730\u65e5\u5fd7\u5730\u5740\uff0c\u6b63\u5f0f\u73af\u5883\u8bf7\u52a1\u5fc5\u5207\u6362\u4e3a\u963f\u91cc\u4e91\u5730\u5740
log4j.appender.dailyFile.File=/imooc/logs/itzixi-web/log.log4j
log4j.appender.dailyFile.DatePattern='.'yyyy-MM-dd
log4j.appender.dailyFile.layout=org.apache.log4j.PatternLayout
log4j.appender.dailyFile.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} [%t] [%l] - [%p] %m%n
各个工程的pom文件配置就完成了。下面我们需要通过逆向工程生成mapper映射类类,实体类,mapper xml文件。