系统设计及基础环境配置实现

第一部分 系统设计

一、技术选型

确定技术平台以及开发和部署相关工具及版本
统一的开发环境、测试环境、生产环境相关依赖的版本

在这里插入图片描述

二、数据库设计

  1. 实体设计
  2. 表设计
    数据库名:forum_db
    公共字段:无特殊要求的情况下,每张表必须有长整型的自增主键,删除状态,创建事件,更新时间如下所示。
    在这里插入图片描述

数据库中的删除一般不是实际意义的删除,是通过修改状态去更新数据而已,这样做的好处就是方便回滚之前的数据操作

  • 确定论坛中的类,对应到数据库中的表
    在这里插入图片描述

  • 为类确定属性

属性要求:
与类强相关
可以用简单类型表示

可以根据现有的论坛系统去观察分析看属性
在这里插入图片描述

  1. SQL语句编写
    这里使用的是navicat编写。各表的字段信息
-- 创建数据库
drop database if exists forum_db;
create database forum_db character set utf8mb4 collate utf8mb4_general_ci;

-- 选择数据库
use forum_db;
-- 创建用户表 t_user
drop table if exists t_user;
create table t_user(
        id bigint primary key auto_increment comment '编号,自增主键',
        username varchar(20) not null unique comment '用户名,唯一',
        password varchar(32) not null comment '加密后的密码',
        nickname varchar(50) not null comment '昵称',
        phoneNum varchar(20) not null comment '手机号',
        email varchar(50) not null comment '电子邮箱',
        gender tinyint not null default 0 comment '性别,0—女,1—男,2—保密',
        salt varchar(32) not null comment '给密码加盐',
        avatarUrl varchar(255) comment '用户头像路径',
        articleCount int not null default 0 comment '发帖数量',
        isAdmin tinyint not null default 0 comment '是否是管理员,0—否,1—是',
        remark varchar(100) comment '备注,自我介绍',
        state tinyint not null default 0 comment '状态,0—正常,1—禁言',
        deleteState tinyint not null default 0 comment '是否删除,0—否,1—是',
        createTime datetime not null comment '创建时间,精确到秒',
        updateTime datetime not null comment '更新时间,精确到秒'
);
-- 创建版块表 t_board
drop table if exists t_board;
create table t_board(
        id bigint primary key auto_increment comment '编号,自增主键',
        name varchar(50) not null comment '版块名',
        articleCount int not null default 0 comment '帖子数量',
        sort int not null default 0 comment '排序优先级,升序',
        state tinyint not null default 0 comment '状态,0—正常,1—禁用',
        deleteState tinyint not null default 0 comment '是否删除,0—否,1—是',
        createTime datetime not null comment '创建时间,精确到秒',
        updateTime datetime not null comment '更新时间,精确到秒'
        
);
-- 创建帖子表
drop table if exists t_article;
create table t_article(
        id bigint primary key auto_increment comment '编号,自增主键',
        boardId bigint not null comment '编号,自增主键',
        userId bigint not null comment '发帖人关联用户编号',
        title varchar(100) not null comment '帖子标题',
        content text not null comment '帖子正文',
        visitCount int not null default 0 comment '访问量',
        replyCount int not null default 0 comment '回复数',
        likeCount int not null default 0 comment '点赞数',
        state tinyint not null default 0 comment '状态,0—正常,1—禁用',
        deleteState tinyint not null default 0 comment '是否删除,0—否,1—是',
        createTime datetime not null comment '创建时间,精确到秒',
        updateTime datetime not null comment '更新时间,精确到秒'
);
-- 帖子回复表
drop table if exists t_article_reply;
create table t_article_reply(
        id bigint primary key auto_increment comment '编号,自增主键',
        articleId bigint not null comment '关联帖子编号',
        postUserId bigint not null comment '楼主用户,关联用户编号',
        replyId bigint not null comment '关联回复编号,支持楼中楼',
        replyUserId bigint not null comment '楼主下的回复用户编号,支持楼中楼',
        content varchar(500) not null comment '回帖内容',
        likeCount int not null comment '回帖数量',
        state tinyint not null default 0 comment '状态,0—正常,1—禁用',
        deleteState tinyint not null default 0 comment '是否删除,0—否,1—是',
        createTime datetime not null comment '创建时间,精确到秒',
        updateTime datetime not null comment '更新时间,精确到秒'
);
-- 站内信息表
drop table if exists t_message;
create table t_message(
        id bigint primary key auto_increment comment '编号,自增主键',
        postUserId bigint not null comment '发送者,关联用户编号',
        receiveUserId bigint not null comment '接收者,关联用户编号',
        content varchar(255) not null comment '内容',
        state tinyint not null default 0 comment '状态,0—正常,1—禁用',
        deleteState tinyint not null default 0 comment '是否删除,0—否,1—是',
        createTime datetime not null comment '创建时间,精确到秒',
        updateTime datetime not null comment '更新时间,精确到秒'
);

三、环境搭建

参照上面的技术选型进行环境搭建配置
  1. 检查JDK
    在这里插入图片描述

  2. 检查MySQL数据库
    在这里插入图片描述

  3. 检查Maven
    确认版本3.5.x及以上
    原本的打包方式是本地开发好了打包成jar包然后直接部署到服务器上,然后因为打包成jar包上传的时候,网络资源消耗比较大,加上所有的资源都是以jar包的形式传输,过程可能是不安全的,所以采用代码仓库的方式,本地只需要将代码传到仓库,服务器就可以直接去仓库中取,然后此时的生产环境(服务器)中需要安装Maven,生成jar,运行即可。
    在这里插入图片描述
    虽然项目中会自带有Maven,但是建议在本地也安装一个Maven。
    官网下载:官网下载maven
    在这里插入图片描述
    在这里插入图片描述
    配置环境变量
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    配置国内的镜像
    在这里插入图片描述
    把默认的镜像去掉,加入以下访问镜像,然后保存即可。

<!--加入如下mirror节点,使用国内阿里云仓库镜像-->
        <mirror>
                <id>aliyun-public</id>
                <mirrorOf>*</mirrorOf>
                <name>aliyun public</name>
                <url>https://maven.aliyun.com/repository/public</url>
        </mirror>
        <mirror>
                <id>aliyun-central</id>
                <mirrorOf>*</mirrorOf>
                <name>aliyun central</name>
                <url>https://maven.aliyun.com/repository/central</url>
        </mirror>
        <mirror>
                <id>aliyun-spring</id>
                <mirrorOf>*</mirrorOf>
                <name>aliyun spring</name>
                <url>https://maven.aliyun.com/repository/spring</url>
        </mirror>

至此本地maven就配置好啦。
我们也可以去idea中修改maven为我们本地安装的。
5. 检查GITEE + GIT

首先注册账号gitee
本地安装git,终端输入git --version查看版本

在这里插入图片描述

  1. 安装插件
    安装Spring Boot Helper,用于创建Spring Boot 项目。要注意插件和idea版本要匹配。
    在这里插入图片描述

  2. 安装lombok
    在这里插入图片描述

  3. 创建仓库
    在这里插入图片描述
    在这里插入图片描述

  4. 登录GITEE创建仓库并复制仓库地址
    在这里插入图片描述

  5. 克隆到本地
    在本地的项目目录中打开终端输入

git clone + 仓库地址

在这里插入图片描述
在这里插入图片描述
10.创建工程
这里是通过社区版安装的Spring Boot Helper创建
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
项目创建成功。
但是会看到这样一个提示,没有Maven工程,所以需要识别Maven工程
在这里插入图片描述
首先先去到pom.xml中
在这里插入图片描述
然后就可以加入maven工程了
在这里插入图片描述
在项目右边可以看到maven列表证明maven创建成功啦
在这里插入图片描述
至此项目创建成功。

  1. 调整项目配置信息
    (1) 修改maven为本地的
    在这里插入图片描述
    (2) 设置编码集(UTF8)
    在这里插入图片描述
    在这里插入图片描述
    (3) 代码补全
    在这里插入图片描述
    (4) 自动导包
    在这里插入图片描述
    (5) 开启热部署
    在pom.xm看有没有下面这段依赖,有的话说明是配置过的。
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-devtools</artifactId>
   <scope>runtime</scope>
   <optional>true</optional>
</dependency>

在这里插入图片描述
或者在设置中设置
在这里插入图片描述
在这里插入图片描述
热部署完成。
(6) 打包过程中明确指定JDK版本
在pom.xml中定义一些全局的变量配置

<!--    定义一些全局的配置参数-->
   <properties>
      <java.version>1.8</java.version>
<!--      编译环境JDK版本-->
      <maven.compiler.source>${java.version}</maven.compiler.source>
<!--      运行环境JVM版本-->
      <maven.compiler.target>${java.version}</maven.compiler.target>
<!--      构建项目指定编码集-->
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>

在这里插入图片描述
(7) 选择yml文件或者properties文件
yaml 可以写成 yml,两者等价
在项目中的话我们可以选择yml,也可以选择properties,两个文件也可以同时存在,在本项目中的话统一使用yml文件,删除原来resources目录下的application.properties文件,并创建application.yml文件。
在这里插入图片描述
测试项目运行,在test目录下测试。
在这里插入图片描述
(8) Spring Boot 项目测试接口
在fourm包下创建controller包,在controller包底下创建一个测试类
在这里插入图片描述
在此之前可以去yml配置中设置一下服务器访问端口,默认是8080,为了安全的话可以自定义设置
在这里插入图片描述
然后再TestController类中写一个测试方法进行访问
在这里插入图片描述
可以看到测试成功。
在这里插入图片描述
(9) 给输出日志信息设置彩色打印
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
(10) 打印日志输出保存设置
在这里插入图片描述
在这里插入图片描述
13. 推送到git远程仓库
使用idea中的git插件,commit直接提交
在这里插入图片描述
命令行方式
直接使用idea的终端执行命令,这里要注意的是配置git安装的环境变量,系统、用户的都要配置。(bin和cmd)

查看当前状态,列出未修改后添加的文件
git status

在这里插入图片描述

添加修改后的文件到暂存区,再次运行 git status,上面的文件会变成绿色显示
git add .
. 表示当前目录

在这里插入图片描述

提交到本地仓库
git commit -m '备注信息'

在这里插入图片描述

推送到远程仓库
git push

在这里插入图片描述
推送完成,可以去到远程查看。
在这里插入图片描述
至此环境的搭建及相关文件配置就完成啦。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小哈不会玩

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值