「小程序JAVA实战」springboot的后台搭建(31)

发布时间:2020-07-06 18:05:51 作者:IT人故事
来源:网络 阅读:868

根据下面的图,我们来建立下对应的springboot的聚合项目。源码:https://github.com/limingios/wxProgram.git 中的wx-springboot

「小程序JAVA实战」springboot的后台搭建(31)

maven主工程

选择Maven Project

「小程序JAVA实战」springboot的后台搭建(31)

选择路径

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

双击pom添加springboot的maven,查看maven的仓库中,springboot(1)的最后一个版本是1.5.15release直接使用1.5.15release!

「小程序JAVA实战」springboot的后台搭建(31)

<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.0</modelVersion>
  <groupId>com.idig8</groupId>
  <artifactId>wx-springboot</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>

  <name>小程序JAVA实战</name>
    <description>
        小程序
        maven
        springmvc
        springboot
        mybatis
        mybatis-pagehelper
        redis
        ffmpeg
        druid
        mariadb/mysql
        zookeeper音频操作
       出品:
        个人网站:https://idig8.com
        公众号:编程坑太多      
    </description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.12.RELEASE</version>
        <relativePath/>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>
</project>

maven子工程

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

点击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.0</modelVersion>
  <parent>
    <groupId>com.idig8</groupId>
    <artifactId>wx-springboot</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>wx-springboot-common</artifactId>

  <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <exclusions>
                <!-- 排除springboot默认的logback日志框架 -->
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- 引入log4j日志依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j</artifactId>
            <version>1.3.8.RELEASE</version>
        </dependency>

        <!-- 引入spring aop依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
            </exclusions>
        </dependency>

        <!-- 资源配置 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <!-- 阿里开源数据源 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.1.0</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.41</version>
        </dependency>

        <!-- mybatis -->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.3.1</version>
        </dependency>
        <!--mapper -->
        <dependency>
            <groupId>tk.mybatis</groupId>
            <artifactId>mapper-spring-boot-starter</artifactId>
            <version>1.2.4</version>
        </dependency>
        <!--pagehelper -->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.2.3</version>
        </dependency>

        <!-- apache 工具类 -->
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.11</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.3.2</version>
        </dependency>

        <!-- swagger2 配置 -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.4.0</version>
        </dependency>

        <!-- 引入 redis 依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>2.9.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-redis</artifactId>
            <version>1.8.7.RELEASE</version>
        </dependency>

        <!-- 引入zookeeper -->
        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-framework</artifactId>
            <version>4.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.zookeeper</groupId>
            <artifactId>zookeeper</artifactId>
            <version>3.4.11</version>
        </dependency>
        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-recipes</artifactId>
            <version>4.0.0</version>
        </dependency>

    </dependencies>
</project>

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

点击pom 添加依赖common依赖

「小程序JAVA实战」springboot的后台搭建(31)

选择common作为依赖

「小程序JAVA实战」springboot的后台搭建(31)

pojo的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.0</modelVersion>
  <parent>
    <groupId>com.idig8</groupId>
    <artifactId>wx-springboot</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>wx-springboot-pojo</artifactId>

  <dependencies>
    <dependency>
        <groupId>com.idig8</groupId>
        <artifactId>wx-springboot-common</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
  </dependencies>

</project>

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

点击pom 添加依赖pojo依赖

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

mapper的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.0</modelVersion>
  <parent>
    <groupId>com.idig8</groupId>
    <artifactId>wx-springboot</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>wx-springboot-mapper</artifactId>
  <dependencies>
    <dependency>
        <groupId>com.idig8</groupId>
        <artifactId>wx-springboot-pojo</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
  </dependencies>
</project>

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

点击pom 添加依赖mapper依赖

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

service 的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.0</modelVersion>
  <parent>
    <groupId>com.idig8</groupId>
    <artifactId>wx-springboot</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>wx-springboot-service</artifactId>
  <dependencies>
    <dependency>
        <groupId>com.idig8</groupId>
        <artifactId>wx-springboot-mapper</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
  </dependencies>
</project>

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

点击pom 添加依赖service依赖

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

api 的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.0</modelVersion>
  <parent>
    <groupId>com.idig8</groupId>
    <artifactId>wx-springboot</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>wx-springboot-api</artifactId>
  <dependencies>
    <dependency>
        <groupId>com.idig8</groupId>
        <artifactId>wx-springboot-service</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
  </dependencies>
</project>

构建完毕

package com.idig8;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

import tk.mybatis.spring.annotation.MapperScan;

@SpringBootApplication
@ComponentScan(basePackages= {"com.idig8"})
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}

「小程序JAVA实战」springboot的后台搭建(31)

log4j.properties

log4j.rootLogger=INFO,console,dailyFile
# TODO 发布到阿里云记得添加,另外控制台不输出(只输出warn或者error信息)
#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

# 定期滚动日志文件,每天都会生成日志
log4j.appender.dailyFile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.dailyFile.encoding=UTF-8
log4j.appender.dailyFile.Threshold=INFO
# TODO 本地日志地址,正式环境请务必切换为阿里云地址
log4j.appender.dailyFile.File=/idig8/logs/wx-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

「小程序JAVA实战」springboot的后台搭建(31)

application.properties


############################################################ # # 配置数据源相关   使用阿里巴巴的 druid 数据源 # ############################################################ spring.datasource.url=jdbc:mysql://ip:3306/test spring.datasource.username=XXXXXX spring.datasource.password=XXXXXX 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.idig8.pojo mybatis.mapper-locations=classpath:mapper/*.xml # 通用 Mapper 配置 mapper.mappers=com.idig8.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

启动 Application.java

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

properties 插件

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

「小程序JAVA实战」springboot的后台搭建(31)

PS:spring boot的聚合工程基本搭建完成。下一步就开始搭建api接口开发。


推荐阅读:
  1. 「小程序JAVA实战」小程序多媒体组件(27)
  2. 「小程序JAVA实战」小程序导航组件(26)

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

小程序 微信小程序 springboot

上一篇:python 学习导图

下一篇:第一章 Shell基础知识

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》