搭建父工程thc-videos-dev .
具体的搭建过程, 可以参考我的另外一篇文章, 链接如下
https://blog.csdn.net/qq_33229669/article/details/88670997
pom文件的内容如下
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0modelVersion>
<groupId>com.thcgroupId>
<artifactId>thc-videos-devartifactId>
<version>1.0-SNAPSHOTversion>
<modules>
<module>thc-videos-dev-commonmodule>
<module>thc-videos-dev-pojomodule>
<module>thc-videos-dev-mappermodule>
<module>thc-videos-dev-servicemodule>
<module>thc-videos-dev-mini-apimodule>
modules>
<packaging>pompackaging>
<name>微信小程序-实战name>
<description>
小程序
maven
springmvc
springboot
mybatis
mybatis-pagehelper
redis
ffmpeg
druid
mariadb/mysql
zookeeper音频操作
description>
<parent>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-parentartifactId>
<version>1.5.12.RELEASEversion>
<relativePath/>
parent>
<properties>
<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
<java.version>1.8java.version>
properties>
project>
在第一步的基础上, 创建common 子模块, 其pom文件的内容如下
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>thc-videos-devartifactId>
<groupId>com.thcgroupId>
<version>1.0-SNAPSHOTversion>
parent>
<modelVersion>4.0.0modelVersion>
<artifactId>thc-videos-dev-commonartifactId>
<properties>
<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
properties>
<dependencies>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starterartifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-loggingartifactId>
exclusion>
exclusions>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-log4jartifactId>
<version>1.3.8.RELEASEversion>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-aopartifactId>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-webartifactId>
<exclusions>
exclusions>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-configuration-processorartifactId>
<optional>trueoptional>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-thymeleafartifactId>
dependency>
<dependency>
<groupId>com.alibabagroupId>
<artifactId>druidartifactId>
<version>1.1.0version>
dependency>
<dependency>
<groupId>com.alibabagroupId>
<artifactId>druid-spring-boot-starterartifactId>
<version>1.1.0version>
dependency>
<dependency>
<groupId>mysqlgroupId>
<artifactId>mysql-connector-javaartifactId>
<version>5.1.41version>
dependency>
<dependency>
<groupId>org.mybatis.spring.bootgroupId>
<artifactId>mybatis-spring-boot-starterartifactId>
<version>1.3.1version>
dependency>
<dependency>
<groupId>tk.mybatisgroupId>
<artifactId>mapper-spring-boot-starterartifactId>
<version>1.2.4version>
dependency>
<dependency>
<groupId>com.github.pagehelpergroupId>
<artifactId>pagehelper-spring-boot-starterartifactId>
<version>1.2.3version>
dependency>
<dependency>
<groupId>commons-codecgroupId>
<artifactId>commons-codecartifactId>
<version>1.11version>
dependency>
<dependency>
<groupId>org.apache.commonsgroupId>
<artifactId>commons-lang3artifactId>
<version>3.4version>
dependency>
<dependency>
<groupId>org.apache.commonsgroupId>
<artifactId>commons-ioartifactId>
<version>1.3.2version>
dependency>
<dependency>
<groupId>io.springfoxgroupId>
<artifactId>springfox-swagger2artifactId>
<version>2.4.0version>
dependency>
<dependency>
<groupId>io.springfoxgroupId>
<artifactId>springfox-swagger-uiartifactId>
<version>2.4.0version>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-data-redisartifactId>
dependency>
<dependency>
<groupId>redis.clientsgroupId>
<artifactId>jedisartifactId>
<version>2.9.0version>
dependency>
<dependency>
<groupId>org.springframework.datagroupId>
<artifactId>spring-data-redisartifactId>
<version>1.8.7.RELEASEversion>
dependency>
<dependency>
<groupId>org.apache.curatorgroupId>
<artifactId>curator-frameworkartifactId>
<version>4.0.0version>
dependency>
<dependency>
<groupId>org.apache.zookeepergroupId>
<artifactId>zookeeperartifactId>
<version>3.4.11version>
dependency>
<dependency>
<groupId>org.apache.curatorgroupId>
<artifactId>curator-recipesartifactId>
<version>4.0.0version>
dependency>
dependencies>
project>
其pom文件的内容如下
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>thc-videos-devartifactId>
<groupId>com.thcgroupId>
<version>1.0-SNAPSHOTversion>
parent>
<modelVersion>4.0.0modelVersion>
<artifactId>thc-videos-dev-pojoartifactId>
<dependencies>
<dependency>
<groupId>com.thcgroupId>
<artifactId>thc-videos-dev-commonartifactId>
<version>1.0-SNAPSHOTversion>
dependency>
dependencies>
project>
其pom文件的内容如下
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>thc-videos-devartifactId>
<groupId>com.thcgroupId>
<version>1.0-SNAPSHOTversion>
parent>
<modelVersion>4.0.0modelVersion>
<artifactId>thc-videos-dev-mapperartifactId>
<dependencies>
<dependency>
<groupId>com.thcgroupId>
<artifactId>thc-videos-dev-pojoartifactId>
<version>1.0-SNAPSHOTversion>
dependency>
dependencies>
project>
其pom文件的内容如下
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>thc-videos-devartifactId>
<groupId>com.thcgroupId>
<version>1.0-SNAPSHOTversion>
parent>
<modelVersion>4.0.0modelVersion>
<artifactId>thc-videos-dev-serviceartifactId>
<dependencies>
<dependency>
<groupId>com.thcgroupId>
<artifactId>thc-videos-dev-mapperartifactId>
<version>1.0-SNAPSHOTversion>
dependency>
dependencies>
project>
其pom文件的内容如下
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>thc-videos-devartifactId>
<groupId>com.thcgroupId>
<version>1.0-SNAPSHOTversion>
parent>
<modelVersion>4.0.0modelVersion>
<artifactId>thc-videos-dev-mini-apiartifactId>
<dependencies>
<dependency>
<groupId>com.thcgroupId>
<artifactId>thc-videos-dev-serviceartifactId>
<version>1.0-SNAPSHOTversion>
dependency>
dependencies>
project>
在此模块中,创建启动类
package com.thc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
/**
* 类名称:Application
* 类描述:启动类
*
* @author:
* 创建时间:2019/4/18 19:22
* Version 1.0
*/
@SpringBootApplication
public class Application {
public static void main(String[] args){
SpringApplication.run(Application.class);
}
}
创建一个Controller 接口用于测试
package com.thc.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 类名称:HelloWorldController
* 类描述:Controller 测试类
*
* @author:
* 创建时间:2019/4/18 19:31
* Version 1.0
*/
@RestController
public class HelloWorldController {
@GetMapping("/hello")
public String hello(){
return "hello";
}
}
在此模块中的resources目录中,创建application.properties 文件, 内容如下
############################################################
#
# REDIS 配置
#
############################################################
# Redis数据库索引(默认为0)
#spring.redis.database=1
## Redis服务器地址
#spring.redis.host=192.168.1.209
## Redis服务器连接端口
#spring.redis.port=6379
## Redis服务器连接密码(默认为空)
#spring.redis.password=imooc
## 连接池最大连接数(使用负值表示没有限制)
#spring.redis.pool.max-active=1000
## 连接池最大阻塞等待时间(使用负值表示没有限制)
#spring.redis.pool.max-wait=-1
## 连接池中的最大空闲连接
#spring.redis.pool.max-idle=10
## 连接池中的最小空闲连接
#spring.redis.pool.min-idle=2
## 连接超时时间(毫秒)
#spring.redis.timeout=0
############################################################
#
# 配置数据源相关 使用阿里巴巴的 druid 数据源
#
############################################################
spring.datasource.url=jdbc:mysql://118.24.145.136:3306/javaweixin6-video-dev
spring.datasource.username=root
spring.datasource.password=utry1234
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 配置
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 服务端相关配置
#
############################################################
# 配置api端口号
server.port=8081
############################################################
# Server - tomcat 相关常用配置
############################################################
# tomcat的URI编码
server.tomcat.uri-encoding=UTF-8
运行启动类,启动项目,可以看到项目运行在8081端口
在浏览器中输入http://localhost:8081/hello
响应的数据如下 ,代表成功响应了数据