diff --git a/README.md b/README.md index a093af2..dd9dff9 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ ## 开始使用 -> 所需环境:Java JDK 8+,Maven,MySQL 5.7+,nodejs等 +> 所需环境:Java JDK 8,Maven,MySQL 5.7+,nodejs,Redis等 ### 安装环境 @@ -29,28 +29,208 @@ # 下载地址:https://nodejs.org/dist/v16.14.0/node-v16.14.0-x64.msi # 安装 JDK 8 +# TODO # 安装 Maven +# TODO -# 安装 MySQL 5.7 +# 安装 MySQL (5.7 以上版本) +# TODO -# 导入数据库SQL脚本 +# 安装 Redis +# TODO -# nodemon(可选) -# 开发使用 nodemon,代码变动后自动重启。 +# pm2 +npm i pm2 -g + +# nodemon (可选) +# 开发使用 nodemon (代码变动后自动重启) # 使用以下代码安装 nodemon npm i nodemon -g ``` +### 环境配置 + +#### 配置国内镜像源 + +##### 配置 npm 国内镜像源 + +```bash +# 查看当前配置的镜像源 默认为: https://registry.npmjs.org/ +npm config get registry + +# 修改为国内镜像源 这里使用淘宝镜像源: https://registry.npm.taobao.org/ +npm config set registry https://registry.npm.taobao.org/ +``` + + + +##### 配置 Maven 国内镜像源 + +编辑 Maven 安装目录下 `conf/settings.xml` 文件,如下 + +```xml + + + + + alimaven + aliyun maven + https://maven.aliyun.com/repository/public + central + + + +``` + + + +### 项目配置 + +```bash +# 配置 nginx.conf +# TODO + +# [前端] +# 配置后台 Api 地址 +# TODO +# 配置前端网站名称 +# TODO + +# [后端] +# TODO +``` + +配置好后,需要重启 nginx + +```bash +# 重启 nginx +nginx -s reload +# 或者使用其他重启命令 +# 例如 Ubuntu 系统下使用 systemctl restart nginx +``` + + + +### 处理依赖 + +```bash +# [前端] +npm install + +# [后端] +mvn clean install +``` + + + +### 数据导入 + +```bash +# [数据库] +# 导入数据库 SQL 脚本 +# TODO +``` + + + +### 编译后端项目 + +```bash +mvn clean install + +# 如果提示: Cannot create resource output directory: xxx +# 那么说明权限不够,在前面加上 sudo +# sudo mvn clean install +``` + +编译成功后,可以看到如下输出(其中有 `BUILD SUCCESS`): + +```bash +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESS +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 12:17 min +[INFO] Finished at: 2022-04-03T14:22:18+08:00 +[INFO] ------------------------------------------------------------------------ +``` + + + +### 启动项目 + +```bash +# [前端] +# 启动前端服务 (默认监听 3000 端口) +npm run prod + + +# [后端] +# 启动后端服务 (默认监听 8090 端口) +mvn install -Djar.forceCreation spring-boot:run +# 如果提示: Cannot create resource output directory: xxx +# 那么说明权限不够,在前面加上 sudo +# sudo mvn install -Djar.forceCreation spring-boot:run + +# 启动 nginx +# TODO +``` + +若启动时提示以下 `WARNING`,是因为 `JDK` 版本过高,一般不影响使用。 + +```bash +WARNING: An illegal reflective access operation has occurred +WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) +WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1 +WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations +WARNING: All illegal access operations will be denied in a future release +``` + + + + + +### 停止项目 + +```bash +# 停止 nginx +# 有如下几种停止方式 +nginx -s quit # 从容停止 +nginx -s stop # 立即停止 +systemctl stop nginx # 使用 systemctl 停止 +# 也可直接杀掉 nginx 进程 + +# 停止前端服务 +npm run prod-stop + +# 停止后端服务 +# TODO +``` + + + ## 功能展示 ### 功能列表 - [x] 首页。简约(说白了其实就是懒),一个搜索框就够了。后期考虑添加热门搜索功能。 -- [ ] 书籍列表页,也是搜索结果页。就是一个书单列表,带分页功能。 -- [ ] 书籍详情页。主要是显示书籍的各种详细信息(书名,简介,缩略图等),还有下载方式,同时还有反馈功能(连接失效反馈,版权问题申诉下架等) +- [x] 书籍列表页,也是搜索结果页。就是一个书单列表,带分页功能。 +- [x] 书籍详情页。主要是显示书籍的各种详细信息(书名,简介,缩略图等),还有下载方式,同时还有反馈功能(连接失效反馈,版权问题申诉下架等) +- [x] 分类列表页 +- [x] 分类详情页 - [ ] 管理员后台。 - [ ] 用户登录后台。 @@ -74,15 +254,18 @@ npm i nodemon -g **对象存储**对接腾讯云COS存储(`cos_api`)。 +**第三方登录**使用 `JustAuth` 开源项目(配合 `okhttp3`) + ## 开发工具 -前端:VS Code,后端:idea,数据库:MySQL +前端:VS Code,后端:idea,数据库:Navicat + +> 以上为项目开发时所使用的开发工具,也可以使用其他的开发工具打开,但建议使用以上工具打开本项目,避免产生一些莫名错误。 ## 注意事项 - nginx启动目录不能包含中文,否则无法启动 - diff --git a/bookshelfplus-frontend/package.json b/bookshelfplus-frontend/package.json index dd0dd35..ffda4a2 100644 --- a/bookshelfplus-frontend/package.json +++ b/bookshelfplus-frontend/package.json @@ -7,6 +7,7 @@ "dev": "nodemon", "test": "set NODE_ENV=production & nodemon", "prod": "set NODE_ENV=production & pm2 start app.js --name bookshelfplus-frontend", + "prod-stop": "pm2 stop bookshelfplus-frontend", "clean": "node cleanup.js" }, "description": "书栖网", diff --git a/bookshelfplus-frontend/public/favicon.ico b/bookshelfplus-frontend/public/favicon.ico index 9416778..993419e 100644 Binary files a/bookshelfplus-frontend/public/favicon.ico and b/bookshelfplus-frontend/public/favicon.ico differ diff --git a/server/nginx/conf/nginx.conf b/server/nginx/conf/nginx.conf index dfe84fb..7921e77 100644 --- a/server/nginx/conf/nginx.conf +++ b/server/nginx/conf/nginx.conf @@ -42,7 +42,7 @@ http { server 127.0.0.1:3000; } - upstream backendSprintbootServer { + upstream backendSpringbootServer { server 127.0.0.1:8090; } @@ -76,7 +76,7 @@ http { # 在nginx 作为代理服务器时,设置的IP列表,会把经过的机器ip,代理机器ip都记录下来,用 【,】隔开;代码中用 echo $x-forwarded-for |awk -F, '{print $1}' 来作为源IP proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_pass http://backendSprintbootServer/api/; + proxy_pass http://backendSpringbootServer/api/; index index.html index.htm; } diff --git a/server/nginx/html/50x.html b/server/nginx/html/50x.html index c46c511..b4ec7b2 100644 --- a/server/nginx/html/50x.html +++ b/server/nginx/html/50x.html @@ -15,7 +15,7 @@

Oh No! 服务器要炸啦!

对不起,当前网站访问量过大,已超出服务器的最大处理能力,已触发自动保护机制。也请您不要频繁刷新,让服务器喝口水、喘口气儿吧~

我们还是一如既往完全免费的书栖网,在网站不可用期间,大家可以前往Git仓库下载电子书。

-

本站不接受打赏,由程序员小墨开发并开源,如果您想支持本站,可以去开源仓库或去B站为我点个Star,如果您有能力的话,也欢迎前往项目开源仓库为项目提交Pr。

+

本站由程序员小墨开发并开源,不接受打赏。如果您想支持本站,可以去开源仓库或去B站为我点个Star,如果您有能力的话,也欢迎前往项目开源仓库为项目提交Pr。

感谢大家的支持。

书栖网