1、寫在前面
其實作在可以寫博客的在線網站很多,有CSDN,有簡書,甚至連GitHub都能寫博客,而且還有Wordpress可以輕松構建個人博客網站,不過還是想弄個自己的個人博客網站,從頭到尾自己搞的那種,就當是熟練下寫專案的技能吧,于是就寫了這個PersonalBlog系統,
2、專案簡介
2.1 功能羅列
PersonalBlog是用Java開發的個人博客系統,我開發這個專案最初的打算是先出一個原型,然后再不斷改進,而原型的功能就參考了B站教程-SpringBoot博客,在教程中,作者以管理員和用戶兩個角色的需求羅列了系統所必須的功能,在這些功能上添加了點個人思考,做了下面這個功能的思維導圖:

后端管理包含三大塊內容:博客的增刪改查、分類的增刪改查以及標簽的增刪改查,
前端展示主要負責博客的各種展示:所有博客展示、最新博客展示、按照分類展示以及按照標簽展示等,
我相信好的博客用戶看了肯定會想要說點什么,因此評論功能是必不可少的,這點教程作者跟大多數個人博客的作者一樣,我稱之為非注冊式評論,就是用戶無需注冊,只需要提供昵稱和郵箱,即可對博客進行評論,但是我覺得這對后續回復評論不是很友好,所以這里我采用注冊式評論,用戶需要先注冊登錄一個賬號才能進行評論,同時這也是我的一點期望,打算以后能在個人博客上添加站內郵件的功能,或者即時通訊,
2.2 技術框架
開發PersonalBlog所采用的技術框架如下:
- 前端:Semantic UI框架【由于是原型,前端頁面直接拿教程原始碼里的來用,后期有好的前端模板再修改即可】
- 后端:SpringBoot + SpringSecurity + MyBatis + thymeleaf模板
- 資料庫:MySQL8.0
其實咱們這個博客系統是個小專案,用不著SpringSecurity,不過我想著平常上班用不到這個框架,就加上去練練手,說實話,要不是一邊百度一邊寫專案,我還真搞不定這玩意兒,
2.3 開發工具
- IDEA
- Maven 3
- JDK 8
3、啟動教程
3.1 原始碼匯入
我的原始碼地址:https://gitee.com/AlaGeek/PersonalBlog
工具安裝我就不多說了,這里默認大家已經會用上述開發工具了,首先大家先把原始碼下載下來,因為我是用IDEA開發的,大家可以直接用IDEA打開,然后自行修改Maven地址為你們本地的Maven地址:

如果JDK對不上,也自行修改:

3.2 環境安裝
專案啟動需要連接MySQL,如果大家電腦上沒有安裝MySQL,可以參考這篇博客——使用Docker搭建MySQL服務,安裝的時候請安裝MySQL8.0以上的版本,
安裝完MySQL8.0后,在如下目錄,修改檔案application-dev.properties中MySQL連接地址,

有了MySQL后,運行下列SQL腳本,生成對應資料庫、表結構以及資料:
create database personal_blog;
use personal_blog;
drop table if exists `user`;
create table `user`(
`id` int auto_increment not null primary key comment "唯一索引",
`account` varchar(60) not null comment "賬號",
`password` varchar(255) not null comment "密碼",
`nickname` varchar(60) not null comment "昵稱",
`email` varchar(100) not null comment "郵箱",
`picture` varchar(500) not null default("https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3317240047,2073069235&fm=11&gp=0.jpg") comment "頭像",
`enabled` tinyint(1) not null default(1) comment "用戶狀態",
`create_time` datetime not null comment "創建時間",
`update_time` datetime not null comment "更新時間"
);
drop table if exists `role`;
create table `role`(
`id` int auto_increment not null primary key comment "唯一索引",
`name` varchar(20) not null comment "英文角色名",
`name_zh` varchar(20) not null comment "中文角色名"
);
drop table if exists `user_role_relationship`;
create table `user_role_relationship`(
`id` int auto_increment not null primary key comment "唯一索引",
`user_id` int not null comment "用戶id",
`role_id` int not null comment "角色id"
);
insert into user(`username`,`password`,`nickname`,`email`,`create_time`,`update_time`) values ("admin","$2a$10$PbVanJ6b5WCJT.d5s9ztS.AZBLp8exY.bhQMDUVd7ql4/GOaS8G1a","管理員","2425235803@qq.com",now(),now());
insert into user(`username`,`password`,`nickname`,`email`,`create_time`,`update_time`) values ("user","$2a$10$mZedJKMamVUuTK5ODtbXF.UusRQanWUBHSpHdZbrmsCWn9VYs2tFW","用戶","2395830314@qq.com",now(),now());
insert into role(`name`,`name_zh`) values ("ROLE_ADMIN","管理員");
insert into role(`name`,`name_zh`) values ("ROLE_READER","讀者");
insert into user_role_relationship(`user_id`,`role_id`) values (1,1);
insert into user_role_relationship(`user_id`,`role_id`) values (2,2);
drop table if exists `post`;
create table `post`(
`id` int auto_increment not null primary key comment "唯一索引",
`title` text not null comment "標題",
`user_id` int not null comment "用戶id",
`first_picture` varchar(500) not null default("https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3317240047,2073069235&fm=11&gp=0.jpg") comment "首圖",
`summary` text not null comment "概述",
`mark` int not null default(0) comment "標記",
`content` longtext comment "正文",
`recommend_status` tinyint(1) not null default(0) comment "推薦狀態",
`reward_status` tinyint(1) not null default(0) comment "打賞狀態",
`copyright_status` tinyint(1) not null default(0) comment "著作權狀態",
`comment_status` tinyint(1) not null default(0) comment "評論狀態",
`publish_status` tinyint(1) not null default(0) comment "發布狀態",
`read_count` int not null default(0) comment "閱讀量",
`create_time` datetime not null comment "創建時間",
`update_time` datetime not null comment "更新時間"
);
drop table if exists `comment`;
create table `comment`(
`id` int auto_increment not null primary key comment "唯一索引",
`user_id` int not null comment "用戶id",
`post_id` int not null comment "文章id",
`content` text not null comment "評論內容",
`state` int not null default(1) comment "審核狀態",
`upvote_count` int not null default(0) comment "點贊數",
`create_time` datetime not null comment "創建時間"
);
drop table if exists `comment_reply`;
create table `comment_reply`(
`id` int auto_increment not null primary key comment "唯一索引",
`comment_id` int not null comment "被回復評論id",
`user_id` int not null comment "用戶id",
`reply_user_id` int not null comment "被回復用戶id",
`content` text not null comment "評論內容",
`state` int not null default(1) comment "審核狀態",
`upvote_count` int not null default(0) comment "點贊數",
`create_time` datetime not null comment "創建時間"
);
drop table if exists `label`;
create table `label`(
`id` int auto_increment not null primary key comment "唯一索引",
`label_name` varchar(20) not null comment "標簽名"
);
drop table if exists `post_label_relationship`;
create table `post_label_relationship`(
`id` int auto_increment not null primary key comment "唯一索引",
`post_id` int not null comment "文章id",
`label_id` int not null comment "標簽id"
);
drop table if exists `clazz`;
create table `clazz`(
`id` int auto_increment not null primary key comment "唯一索引",
`clazz_name` varchar(20) not null comment "分類名"
);
drop table if exists `post_clazz_relationship`;
create table `post_clazz_relationship`(
`id` int auto_increment not null primary key comment "唯一索引",
`post_id` int not null comment "文章id",
`clazz_id` int not null comment "分類id"
);
3.3 啟動專案
直接點擊IDEA中啟動按鈕,如下:

然后在瀏覽器中輸入http://localhost:8080/,即可訪問到如下頁面:

給的SQL陳述句中沒有插入博客資料,所以看到的頁面會跟我的截圖不太一樣,大家可以訪問http://localhost:8080/admin/blog/list這個頁面,點擊圖中紅框里的按鈕新增博客:

4、博客跳轉
關于專案的詳細介紹后續還會寫博客,這部分暫時先空著,
5、寫在后面
PersonalBlog還只是個原型,大家有什么問題還請指出來,有什么優化建議也請提出來,
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/266654.html
標籤:其他
上一篇:學習筆記之——競品分析
