谷粒学院(一) 项目环境搭建

news2025/7/12 7:33:30

一、数据库设计

数据库设计规约

以下规约只针对本模块,更全面的文档参考《阿里巴巴Java开发手册》:五、MySQL数据库

1、库名与应用名称尽量一致

2、表名、字段名必须使用小写字母或数字,禁止出现数字开头,

3、表名不使用复数名词

4、表的命名最好是加上“业务名称_表的作用”。如,edu_teacher

5、表必备三字段:id, gmt_create, gmt_modified

说明:

其中 id 必为主键,类型为 bigint unsigned、单表时自增、步长为 1。

(如果使用分库分表集群部署,则id类型为verchar,非自增,业务中使用分布式id生成器)

gmt_create, gmt_modified 的类型均为 datetime 类型,前者现在时表示主动创建,后者过去分词表示被动更新。

6、单表行数超过 500 万行或者单表容量超过 2GB,才推荐进行分库分表。 说明:如果预计三年后的数据量根本达不到这个级别,请不要在创建表时就分库分表。 

7、表达是与否概念的字段,必须使用 is_xxx 的方式命名,数据类型是 unsigned tinyint (1 表示是,0 表示否)。 

说明:任何字段如果为非负数,必须是 unsigned。 

注意:POJO 类中的任何布尔类型的变量,都不要加 is 前缀。数据库表示是与否的值,使用 tinyint 类型,坚持 is_xxx 的 命名方式是为了明确其取值含义与取值范围。 

正例:表达逻辑删除的字段名 is_deleted,1 表示删除,0 表示未删除。 

8、小数类型为 decimal,禁止使用 float 和 double。 说明:float 和 double 在存储的时候,存在精度损失的问题,很可能在值的比较时,得到不正确的结果。如果存储的数据范围超过 decimal 的范围,建议将数据拆成整数和小数分开存储。

9、如果存储的字符串长度几乎相等,使用 char 定长字符串类型。 

10、varchar 是可变长字符串,不预先分配存储空间,长度不要超过 5000,如果存储长度大于此值,定义字段类型为 text,独立出来一张表,用主键来对应,避免影响其它字段索引效率。

11、唯一索引名为 uk_字段名;普通索引名则为 idx_字段名。

说明:uk_ 即 unique key;idx_ 即 index 的简称

12、不得使用外键与级联,一切外键概念必须在应用层解决。外键与级联更新适用于单机低并发,不适合分布式、高并发集群;级联更新是强阻塞,存在数据库更新风暴的风险;外键影响数据库的插入速度。 

二、搭建项目工程(父工程)

1、工程结构

 

2、模块说明

 

3、创建父工程 

1)创建sprigboot工程guli-parent

在idea开发工具中,使用 Spring Initializr 快速初始化一个 Spring Boot 模块,版本使用:2.2.1.RELEASE

2)删除 src 目录

3)配置 pom.xml

修改版本为 :2.2.1.RELEASE

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>
    <modules>
        <module>service</module>
        <module>common</module>
        <module>canal_clientedu</module>
        <module>infrastructure</module>
    </modules>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.atguigu</groupId>
    <artifactId>guli_parent</artifactId>
    
    <packaging>pom</packaging>

    <version>0.0.1-SNAPSHOT</version>
    <name>guli_parent</name>
    <description>Demo project for Spring Boot</description>

    <!-- 统一管理 jar 包版本 -->
    <properties>
            <java.version>1.8</java.version>
            <guli.version>0.0.1-SNAPSHOT</guli.version>
            <mybatis-plus.version>3.0.5</mybatis-plus.version>
            <velocity.version>2.0</velocity.version>
            <swagger.version>2.7.0</swagger.version>
            <aliyun.oss.version>2.8.3</aliyun.oss.version>
            <jodatime.version>2.10.1</jodatime.version>
            <poi.version>3.17</poi.version>
            <commons-fileupload.version>1.3.1</commons-fileupload.version>
            <commons-io.version>2.6</commons-io.version>
            <httpclient.version>4.5.1</httpclient.version>
            <jwt.version>0.7.0</jwt.version>
            <aliyun-java-sdk-core.version>4.3.3</aliyun-java-sdk-core.version>
            <aliyun-sdk-oss.version>3.1.0</aliyun-sdk-oss.version>
            <aliyun-java-sdk-vod.version>2.15.2</aliyun-java-sdk-vod.version>
            <aliyun-java-vod-upload.version>1.4.11</aliyun-java-vod-upload.version>
            <aliyun-sdk-vod-upload.version>1.4.11</aliyun-sdk-vod-upload.version>
            <fastjson.version>1.2.28</fastjson.version>
            <gson.version>2.8.2</gson.version>
            <json.version>20170516</json.version>
            <commons-dbutils.version>1.7</commons-dbutils.version>
            <canal.client.version>1.1.0</canal.client.version>
            <docker.image.prefix>zx</docker.image.prefix>
            <cloud-alibaba.version>0.2.2.RELEASE</cloud-alibaba.version>
    </properties>

    <!-- 子块继承之后,提供作用:锁定版本 + 子module不用写 groupId 和 version -->
    <dependencyManagement>
        <dependencies>
            <!--Spring Cloud-->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Hoxton.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>${cloud-alibaba.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <!--mybatis-plus 持久层-->
            <dependency>
                <groupId>com.baomidou</groupId>
                <artifactId>mybatis-plus-boot-starter</artifactId>
                <version>${mybatis-plus.version}</version>
            </dependency>

            <!-- velocity 模板引擎, Mybatis Plus 代码生成器需要 -->
            <dependency>
                <groupId>org.apache.velocity</groupId>
                <artifactId>velocity-engine-core</artifactId>
                <version>${velocity.version}</version>
            </dependency>
            <!--swagger-->
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger2</artifactId>
                <version>${swagger.version}</version>
            </dependency>
            <!--swagger ui-->
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger-ui</artifactId>
                <version>${swagger.version}</version>
            </dependency>

            <!--aliyunOSS-->
            <dependency>
                <groupId>com.aliyun.oss</groupId>
                <artifactId>aliyun-sdk-oss</artifactId>
                <version>${aliyun.oss.version}</version>
            </dependency>
            <!--日期时间工具-->
            <dependency>
                <groupId>joda-time</groupId>
                <artifactId>joda-time</artifactId>
                <version>${jodatime.version}</version>
            </dependency>
            <!--xls-->
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi</artifactId>
                <version>${poi.version}</version>
            </dependency>
            <!--xlsx-->
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi-ooxml</artifactId>
                <version>${poi.version}</version>
            </dependency>
            <!--文件上传-->
            <dependency>
                <groupId>commons-fileupload</groupId>
                <artifactId>commons-fileupload</artifactId>
                <version>${commons-fileupload.version}</version>
            </dependency>
            <!--commons-io-->
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>${commons-io.version}</version>
            </dependency>
            <!--httpclient-->
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
                <version>${httpclient.version}</version>
            </dependency>
            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
                <version>${gson.version}</version>
            </dependency>
            <!-- JWT -->
            <dependency>
                <groupId>io.jsonwebtoken</groupId>
                <artifactId>jjwt</artifactId>
                <version>${jwt.version}</version>
            </dependency>
            <!--aliyun-->
            <dependency>
                <groupId>com.aliyun</groupId>
                <artifactId>aliyun-java-sdk-core</artifactId>
                <version>${aliyun-java-sdk-core.version}</version>
            </dependency>
            <dependency>
                <groupId>com.aliyun.oss</groupId>
                <artifactId>aliyun-sdk-oss</artifactId>
                <version>${aliyun-sdk-oss.version}</version>
            </dependency>
            <dependency>
                <groupId>com.aliyun</groupId>
                <artifactId>aliyun-java-sdk-vod</artifactId>
                <version>${aliyun-java-sdk-vod.version}</version>
            </dependency>
            <dependency>
                <groupId>com.aliyun</groupId>
                <artifactId>aliyun-java-vod-upload</artifactId>
                <version>${aliyun-java-vod-upload.version}</version>
            </dependency>
            <dependency>
                <groupId>com.aliyun</groupId>
                <artifactId>aliyun-sdk-vod-upload</artifactId>
                <version>${aliyun-sdk-vod-upload.version}</version>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>fastjson</artifactId>
                <version>${fastjson.version}</version>
            </dependency>
            <dependency>
                <groupId>org.json</groupId>
                <artifactId>json</artifactId>
                <version>${json.version}</version>
            </dependency>
            <dependency>
                <groupId>commons-dbutils</groupId>
                <artifactId>commons-dbutils</artifactId>
                <version>${commons-dbutils.version}</version>
            </dependency>
            <dependency>
                <groupId>com.alibaba.otter</groupId>
                <artifactId>canal.client</artifactId>
                <version>${canal.client.version}</version>
            </dependency>

        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

4、Maven工程落地细节复习 

<packaging>pom</packaging>用在父级工程或聚合工程中,用来做jar包的版本控制。

dependencyManagement说明:

Maven 使用dependencyManagement 元素来提供了一种管理依赖版本号的方式。通常会在一个组织或者项目的最顶层的父POM 中看到dependencyManagement 元素。使用pom.xml 中的dependencyManagement 元素能让所有在子项目中引用一个依赖而不用显式的列出版本号。Maven 会沿着父子层次向上走,直到找到一个拥有dependencyManagement 元素的项目,然后它就会使用这个dependencyManagement 元素中指定的版本号。

dependencyManagement里只是声明依赖,并不实现引入,因此子项目需要显示的声明需要用的依赖。如果不在子项目中声明依赖,是不会从父项目中继承下来的;只有在子项目中写了该依赖项,并且没有指定具体版本,才会从父项目中继承该项,并且version和scope都读取自父pom。如果子项目中指定了版本号,那么会使用子项目中指定的jar版本。

好处:如果有多个子项目都引用同一样依赖,则可以避免在每个使用的子项目里都声明一个版本号,这样当想升级或切换到另一个版本时,只需要在顶层父容器里更新,而不需要一个一个子项目的修改 ;另外如果某个子项目需要另外的一个版本,只需要声明version就可。

三、搭建service模块

添加模块类型是pom

<packaging>pom</packaging>

pom.xml 

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
    </dependency>

    <!--hystrix依赖,主要是用  @HystrixCommand -->
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
    </dependency>

    <!--服务注册-->
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
    </dependency>
    <!--服务调用-->
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-openfeign</artifactId>
    </dependency>

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

    <!--mybatis-plus-->
    <dependency>
        <groupId>com.baomidou</groupId>
        <artifactId>mybatis-plus-boot-starter</artifactId>
    </dependency>

    <!--mysql-->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>

    <!-- velocity 模板引擎, Mybatis Plus 代码生成器需要 -->
    <dependency>
        <groupId>org.apache.velocity</groupId>
        <artifactId>velocity-engine-core</artifactId>
    </dependency>

    <!--swagger-->
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
    </dependency>

    <!--lombok用来简化实体类:需要安装lombok插件-->
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
    </dependency>

    <!--xls-->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
    </dependency>

    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
    </dependency>

    <!--httpclient-->
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
    </dependency>
    <!--commons-io-->
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
    </dependency>
    <!--gson-->
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
    </dependency>
</dependencies>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/17949.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

idea导入springboot项目运行教程

前置要求 ①具备Java环境&#xff0c;并且可以通过Maven进行安装项目依赖&#xff1b; ②具备IntelliJ IDEA工具&#xff0c;推荐专业版&#xff0c;社区版也不影响&#xff1b; ③具备Mysql5.7或以上版本数据库&#xff1b; ④具备Navicat数据库可视化管理工具&#xff1b;…

力扣(LeetCode)14. 最长公共前缀(C++)

模拟 取出 strsstrsstrs 的第一个字符串 strs[0]strs[0]strs[0] &#xff0c; 遍历strs[0]strs[0]strs[0] &#xff0c; 依次比较所有串的当前位置的字符&#xff0c;是否和 strs[0]strs[0]strs[0] 的当前字符相同。 代码展示 class Solution { public:string longestCommon…

现代修谱,如何处理族员离婚再娶,配偶携子改嫁同服弟等情况

现代修谱的那些糟心事 现代修谱过程中&#xff0c;会遇到各种突发情况以及非常棘手的问题。比如说族员离婚再娶&#xff0c;配偶携子改嫁同服弟的情况&#xff0c;族谱该如何记载&#xff1f;很多人都以为这是笔者在说笑&#xff0c;但这种情况在修谱时&#xff0c;不能说很难…

Qt源码解析11-QLineEdit与QValidator关系源码解析

Qt源码解析 索引 Qt源码解析11-QLineEdit与QValidator关系源码解析 测试 本想了解QRegExpValidator的正则表达式如何生效的&#xff0c;发现分析起来比想象的复杂。 测试实例&#xff1a; // regexp: optional - followed by between 1 and 3 digitsQRegExp rx("-?\…

JUC学习笔记——共享模型之管程

在本系列内容中我们会对JUC做一个系统的学习&#xff0c;本片将会介绍JUC的管程部分 我们会分为以下几部分进行介绍&#xff1a; 共享问题共享问题解决方案线程安全分析Monitorsynchronized锁Wait/notify模式之保护性暂停模式之生产者消费者park线程状态转换详解多锁操作活跃…

学生护眼灯怎么选择?推荐学生护眼台灯十大名牌排行榜

护眼台灯是学生们常用的照明产品&#xff0c;也是最受喜爱的护眼产品之一&#xff0c;选购一款护眼台灯要看什么指标呢&#xff1f;除了外观、价格上&#xff0c;更重要的是五个硬性标准&#xff0c;照度、显色、频闪、色温、蓝光。 为了大家更快速选择出合适的台灯&#xff0…

基于51单片机的出租车计价器proteus仿真原理图PCB

功能&#xff1a; 0.本系统采用STC89C52作为单片机 1.LCD1602液晶显示有四个状态 a) 时间显示 b) 时间设置 c) 计价器显示 d) 计价器设置 2.按键切换四个不同显示状态 3.默认为时间显示状态&#xff0c;长按’切换‘键切换至计价器模式 4.在时间显示状态下按‘设置’键可设置时…

C++类的运算符重载.md

11.8 类的运算符重载 运算符重载是一种形式的C多态 运算符重载将充值该的概念扩展到运算符上&#xff0c;允许赋予C运算符多种含义。 C允许将运算符重载扩展到用户定义类型&#xff0c;例如&#xff0c;允许使用将两个对象相加。 11.8.1 操作符重载定义 要重载运算符&#xff0…

FutureTask-详解(二)-ThreadPollExecutor-并发编程(Java)

文章目录1 FutureTask1.1 简介1.2 成员变量1.3 构造方法1.4 主要执行流程分析1.4.1 run任务执行1.4.1.1 run方法1.4.1.2 set(result)方法1.4.1.3 setException(ex)方法1.4.1.4 finishCompletion()方法1.4.2 get() 执行流程1.4.2.1 get()方法1.4.2.2 awaitDone()方法1.4.2.3 rem…

C++获取计算机硬件信息(Linux)

C获取计算机硬件信息&#xff08;Windows&#xff09; https://blog.csdn.net/hhy321/article/details/121258036 C获取计算机硬件信息&#xff08;Linux&#xff09; https://blog.csdn.net/hhy321/article/details/127930470 “春赏百花秋望月&#xff0c;夏有凉风冬观雪。若…

InnoDB之Undo log写入和恢复

1. 前言 为了实现事务的回滚和MVCC&#xff0c;InnoDB设计了Undo log模块&#xff0c;简单来说就是在修改记录前先记下日志&#xff0c;以便之后能将记录恢复成修改前的样子。针对insert、delete、update这三种不同的操作&#xff0c;InnoDB设计了不同类型的undo log&#xff…

Redis 常见问题

一、 什么是Redis&#xff1f; Redis 是一个使用 C 语言写成的&#xff0c;开源的高性能key-value非关系缓存数据库&#xff1b;Redis的数据都基于缓存的&#xff0c;所以很快&#xff0c;每秒可以处理超过 10万次读写操作&#xff1b;Redis也可以实现数据写入磁盘中&#xff…

Spring源码里开天辟地的五个Bean,再介绍一个学习方法

准备工作 首先咱们还是来写一个最简单的例子&#xff1a; 用的还是 https://github.com/xiexiaojing/yuna 里的代码&#xff0c;只是标签和引用都换成了Spring原生的。 配置类就是配置了扫描路径&#xff1a; 在可以被扫描的包路径下定义了一个Bean对象。用了Component注解这…

Java#16(包装类和集合练习)

目录 基本数据类型对应的包装类: 一.添加学生对象并遍历 二.添加用户对象并判断是否存在 三.添加手机对象并返回要求的数据 基本数据类型对应的包装类: byte------>Byte short------->Short char------->Character int------->Integer long------->Long flo…

MRT(MODIS Reprojection Tool) 下载及安装教程

大家下载MODIS数据的时候&#xff0c;大多是hdf的格式数据。HDF数据包括11个波段的数据&#xff08;如下图&#xff09;&#xff0c;假如想要其中一个波段数据&#xff0c;我们需要批量提取&#xff0c;这时就要用到NASA提供的MODIS Reprojection Tool&#xff0c;此工具虽不能…

c++ 指针,new运算符

1、指针相关基础知识&#xff1a; 1.1、指针一般指向变量的地址&#xff0c;等同于变量名前加&&#xff0c;如下&#xff1a; int a 3; int* p; p &a; 1.2、 * 符号被称为间接值运算符或解除引用运算符&#xff0c;将其运用于指针&#xff0c;可以获取指针指向的值…

【Java八股文总结】之IO流

文章目录Java IO流一、IO基础知识1、字节流2、字符流3、字节缓冲流4、打印流5、随机访问流6、字节流和字符流的区别&#xff1f;二、IO设计模式1、装饰器模式2、适配器模式Q&#xff1a;适配器模式和装饰器模式的区别&#xff1f;3、工厂模式4、观察者模式三、IO模型详解&#…

柯桥留学日语培训机构有吗日本人平时都喝什么酒?

日本葡萄酒侍酒大师高野丰先生&#xff0c;带来一瓶在北海道发现的陈年白兰地。 那是2014年的事&#xff0c;高野先生去北海道十胜地区的一家葡萄酒厂考察&#xff0c;在一个多年未开启的葡萄酒储存库的角落里&#xff0c;发现了一只陈旧的酒桶&#xff0c;他很好奇地问酒厂的…

Javaweb filter过滤器 跟 listener监听器

Filter 权限控制&#xff1a;登录才能进数据库等 统一编码&#xff1a;统一各种编码 Filter快速入门 放行前&#xff0c;我们对request里的数据进行处理 处理完&#xff0c;然后放行&#xff0c;携带到对应的资源里去 放行后&#xff0c;对response的数据进行处理 //将re…

C/C++问题:一个指针的大小是多少?怎么理解指针变量的存在

目录 举例 一、 int a; int (*(*v)[])(); 二、 int func(); int (*func)(); 三、 const; int const a; const int a; int const*r; int *const r; 四、一个指针的大小是多少&#xff1f;&#xff08;补充&#xff09; 举例 一、 int a; 可以看到上面声明了一个变…