当前位置: 首页 > article >正文

搭建项目后台系统基础架构

任务描述

1、了解搭建民航后端框架

2、使用IDEA创建基于SpringBoot、MyBatis、MySQL、Redis的Java项目

3、以原项目为参照搭建项目所涉及到的各个业务和底层服务

4、以原项目为例,具体介绍各个目录情况并参照创建相关文件夹

1、创建项目后端 BigData-KongGuan

    BigData-KongGuan项目是当前民航项目的后端程序,负责访问数据为前端提供查询接口,同时提供一些定时任务,例如,将HBase数据查询出来,并推送到Kafka当中,来模拟航空数据的收集过程等。

  • 创建一个基于SpringBoot+MyBatis-Plus的项目:BigData-KongGuan

  • 配置Maven插件,点击菜单“File”-> “Settings”,然后在打开的窗口按如下图所示配置Maven

  • 在com.qrsoft包上点击右键,创建Package包

  • 在项目中需要创建如下图所示的包目录结构和配置文件

  • 项目的包目录结构和配置文件的说明如下

目录

子目录/文件

目录/文件(代码)的说明

src/main/java/com/qrsoft/common/存放一些通用类
src/main/java/com/qrsoft/config/存放SpringBoot的Configuration配置类
src/main/java/com/qrsoft/controller/存放Controller控制器类
src/main/java/com/qrsoft/entity/存放实体类
src/main/java/com/qrsoft/filter/存放过滤器类
src/main/java/com/qrsoft/mapper/存放MyBatis数据访问类
src/main/java/com/qrsoft/service/存放Service接口类
src/main/java/com/qrsoft/util/存放工具类
src/main/java/com/qrsoft/ApplicationStarter.java(BigDataKongGuanApplication.java)SpringBoot的启动程序
src/main/resources/application.yml(application.properties)SpringBoot的配置文件
src/main/resources/hbase.propertiesHBase的配置文件
src/main/resources/kafka.propertiesKafka的配置文件
src/main/resources/log4j.propertiesLog4j日志的配置文件
  • 在项目的pom.xml中添加依赖,最终pom.xml文件如下
 <?xml version="1.0" encoding="UTF-8"?>
<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.qrsoft</groupId>
    <artifactId>BigData-KongGuan</artifactId>
    <version>1.0</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <version>2.4.5</version>
        <artifactId>spring-boot-starter-parent</artifactId>
    </parent>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.4.1</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <!-- JWT -->
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt-impl</artifactId>
            <version>0.11.2</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt-jackson</artifactId>
            <version>0.11.2</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt-api</artifactId>
            <version>0.11.2</version>
        </dependency>
        <!-- Spring Boot Security -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>

        <!-- spring-redis -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>io.lettuce</groupId>
                    <artifactId>lettuce-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
        <dependency>
            <groupId>com.github.xiaoymin</groupId>
            <artifactId>swagger-bootstrap-ui</artifactId>
            <version>1.9.6</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <version>2.9.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka_2.10</artifactId>
            <version>0.10.0.0</version>
            <exclusions>
                <exclusion>
                    <artifactId>slf4j-log4j12</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>log4j</artifactId>
                    <groupId>log4j</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>slf4j-api</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>log4j-slf4j-impl</artifactId>
                    <groupId>org.apache.logging.log4j</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>kafka-clients</artifactId>
                    <groupId>org.apache.kafka</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka-clients</artifactId>
            <version>0.10.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hbase</groupId>
            <artifactId>hbase-client</artifactId>
            <version>1.3.1</version>
            <exclusions>
                <exclusion>
                    <artifactId>log4j</artifactId>
                    <groupId>log4j</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>slf4j-log4j12</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>slf4j-api</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>log4j-slf4j-impl</artifactId>
                    <groupId>org.apache.logging.log4j</groupId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.guava</groupId>
                    <artifactId>guava</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.75</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.6</version>
        </dependency>
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.6.3</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>
  • 更新Maven依赖

  • 最终项目的目录结构如下所示

2、创建项目数据清洗端 BigData-Etl-KongGuan

    BigData-Etl-KongGuan项目是当前民航项目的数据清洗程序,负责数据的ETL等工作。

  • 创建一个基于SpringBoot的项目:BigData-Etl-KongGuan

  • 配置Maven插件,点击菜单“File”-> “Settings”,然后在打开的窗口按如下图所示配置Maven

  • 在com.qrsoft包上点击右键,创建Package包,名为 etl

  • 在com.qrsoft.etl包上点击右键,创建如下所示的包目录结构和配置文件

  • 项目的目录结构说明

目录

子目录/文件

目录/文件(代码)的说明

src/main/java/com/qrsoft/etl/common/存放一些通用类
src/main/java/com/qrsoft/etl/common/db存放数据库连接管理类
src/main/java/com/qrsoft/etl/dao/存放数据访问类
src/main/java/com/qrsoft/etl/dao/entity存放实体类
src/main/java/com/qrsoft/etl/spark/存放Spark数据清洗任务类
src/main/java/com/qrsoft/etl/Task/存放SpringBoot定时任务类
src/main/java/com/qrsoft/etl/util/存放工具类
src/main/java/com/qrsoft/BigDataEtlKongGuanApplication.javaSpringBoot的启动程序 
src/main/resources/application.ymlSpringBoot的配置文件
src/main/resources/config.propertiesmysql的配置文件
src/main/resources/myconfig.propertiesZookeeper的配置文件
src/main/resources/log4j.propertiesLog4j日志的配置文件
  • 在项目的pom.xml中添加依赖,最终pom.xml文件如下
 <?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    
    <groupId>com.qrsoft</groupId>
    <artifactId>etl</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>BigData-Etl-KongGuan</name>
    <description>BigData-Etl-KongGuan</description>
    
    <properties>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <scala-version>2.10</scala-version>
        <spark-version>2.0.2</spark-version>
    </properties>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web-services</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!--spark-->
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-core_${scala-version}</artifactId>
            <version>${spark-version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-streaming_${scala-version}</artifactId>
            <version>${spark-version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-streaming-kafka-0-10_${scala-version}</artifactId>
            <version>${spark-version}</version>
        </dependency>
        <!--Spark-->
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
            <version>4.0.29.Final</version>
        </dependency>
        <!--Kafka-->
        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka_2.10</artifactId>
            <version>0.10.0.0</version>
            <exclusions>
                <exclusion>
                    <artifactId>slf4j-log4j12</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>log4j</artifactId>
                    <groupId>log4j</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>slf4j-api</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>log4j-slf4j-impl</artifactId>
                    <groupId>org.apache.logging.log4j</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>kafka-clients</artifactId>
                    <groupId>org.apache.kafka</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka-clients</artifactId>
            <version>0.10.0.1</version>
        </dependency>
        <!--Kafka-->
        <dependency>
            <groupId>org.apache.hbase</groupId>
            <artifactId>hbase-client</artifactId>
            <version>1.3.1</version>
            <exclusions>
                <exclusion>
                    <artifactId>log4j</artifactId>
                    <groupId>log4j</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>slf4j-log4j12</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>slf4j-api</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>log4j-slf4j-impl</artifactId>
                    <groupId>org.apache.logging.log4j</groupId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.guava</groupId>
                    <artifactId>guava</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.75</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.6</version>
        </dependency>
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
            <classifier>jdk15</classifier>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.4.1</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>
  • 更新Maven依赖

  • 最终项目的目录结构如下所示


http://www.kler.cn/a/274444.html

相关文章:

  • 前端yarn工具打包时网络连接问题排查与解决
  • 智能工厂的设计软件 三种处理单元(NPU/GPU/CPU)及其在深度学习框架中的作用 之5(腾讯云AI代码助手 之3)
  • EasyExcel 导出文件
  • CarWatchdog
  • python:用 sklearn 构建线性回归模型,并评价
  • LeetCode 69. x 的平方根 (C++实现)
  • 【MySQL】MySQL视图
  • c++ 递增的5位数
  • 15届蓝桥杯备赛(2)
  • 管道(acwing,蓝桥杯,二分)
  • P8717 [蓝桥杯 2020 省 AB2] 成绩分析 Python
  • 【洛谷 P9242】[蓝桥杯 2023 省 B] 接龙数列 题解(线性DP)
  • WRF模型运行教程(ububtu系统)--III.运行WRF模型(官网案例)
  • 我的尝试:Codigger + Vim
  • 迷宫问题(c++题解)
  • MQTT建立连接
  • 【C++】每日一题 219 最小栈
  • Leetcode 79. 单词搜索
  • 【进阶五】Python实现SDVRP(需求拆分)常见求解算法——自适应大邻域算法(ALNS)
  • 学习vue3第六节(vue3 中 computed watch watchEffect)
  • 有什么小程序适合个人开发?
  • Aigtek超声功率放大器产品介绍
  • 力扣1. 两数之和
  • 腾讯云服务器多少钱1个月?2024一个月收费阿济格IE吧
  • 数据结构:详解【顺序表】的实现
  • PlantUML Integration 编写短信服务类图