├── .gitignore ├── LICENSE ├── README.md ├── docker-compose.yml ├── images ├── art-list.png ├── article-detail.png ├── create-art.png ├── dashboard.png ├── homepage.png ├── links.png ├── man-art-list.png └── man-links.png ├── step-1-clone.sh └── step-2-build.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # IDE / Editor 2 | .idea 3 | .vscode 4 | .vs 5 | 6 | # clone dir 7 | admin 8 | blog 9 | api 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 WindSnowLi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # w-blog 2 | 3 | ## 描述 4 | 5 | 一个后端使用Spring Boot 2.x、前台使用nuxtJs、后台使用vue的个人博客 6 | 7 | ## 简介 8 | 9 | 1. 链接 10 | - Gitee链接: 11 | - [api](https://gitee.com/windsnowli/w-blog-api): `https://gitee.com/windsnowli/w-blog-api` 12 | - [前台](https://gitee.com/windsnowli/vue-ssr-blog): `https://gitee.com/windsnowli/vue-ssr-blog` 13 | - [后台](https://gitee.com/windsnowli/vue-admin-blog): `https://gitee.com/windsnowli/vue-admin-blog` 14 | - GitHub链接: 15 | - [api](https://github.com/WindSnowLi/w-blog-api): `https://github.com/WindSnowLi/w-blog-api` 16 | - [前台](https://github.com/WindSnowLi/vue-ssr-blog): `https://github.com/WindSnowLi/vue-ssr-blog` 17 | - [后台](https://github.com/WindSnowLi/vue-admin-blog): `https://github.com/WindSnowLi/vue-admin-blog` 18 | 19 | 2. 一个简单的的个人博客项目,共分为了 `前台`、 `后台`、 `api`三个部分。 20 | 21 | - api: 后端基于 `SpringBoot` 。主要依赖 `Mybatis` 、 `Mybatis-Redis` 、 `Redis` 、 `fastjson` 、 `DruidDataSource` 、 `Lombok` 22 | 、 `java-jwt` 、 `aliyun-sdk-oss` 、 `knife4j` 等,数据库使用的是 `MySQL8.0+` 23 | 24 | - 前台: 前台的主要样式是来源于网络上了一个 `BizBlog` 模板,最初来源于哪我不得而知,在原本的基础上改写成了 `nuxtJs` 项目。 25 | - 后台: 后台UI套用的[vue-element-admin](https://github.com/PanJiaChen/vue-element-admin),基本是直接拿来用了,想自己定制着实实力不允许。 26 | 27 | 3. 示例:[绿色食品——菜狗](https://www.blog.hiyj.cn/) 28 | 29 | ## 本地启动 30 | 31 | ### 逐个项目启动 32 | 33 | #### api:前台后台请求的api使用的是同一个项目 34 | 35 | 1. `git clone https://gitee.com/WindSnowLi/w-blog-api.git`或`git clone https://github.com/WindSnowLi/w-blog-api.git` 36 | 克隆项目到本地 37 | 2. `mvn clean install dependency:tree` 安装依赖 38 | 3. 创建数据库,并设置为`UTF8`编码(`utf8mb4`) 39 | 4. 修改环境设置 40 | - 修改开发环境 `application-dev.yml` 和生产环境 `application-prod.yml` 中的数据库配置信息; 41 | - 修改 `redis.properties` 中的 `Redis` 相关信息; 42 | - 注: `knife4j` 只在开发环境中激活。 43 | 44 | 5. `mvn clean package -Dmaven.test.skip=true` 跳过测试并生成 `jar` 包 45 | 6. `java -jar 生成的包名.jar` 运行开发配置环境,初次运行会自动初始化数据库(生产环境可指定加载的配置文件`--spring.profiles.active="prod"`) 46 | 7. 访问 `http://127.0.0.1:9000/doc.html` 查看 `api` 文档 47 | 8. *推荐使用IDEA打开项目文件夹自动处理依赖、方便运行* 48 | 49 | #### 前台 50 | 51 | 1. `git clone https://gitee.com/WindSnowLi/vue-ssr-blog.git`或`git clone https://github.com/WindSnowLi/vue-ssr-blog.git` 52 | 克隆项目到本地 53 | 2. `npm install` 安装依赖 54 | 3. 可修改 `config/sitemap.xml` 文件中的 `host` 地址,用于生成访问地图 55 | 4. 可修改 `nuxt.config.js` 中的端口号 56 | 5. 可修改 `package.json` 文件中的 `script` 中的 `BASE_URL` 来指定后端 `api` 地址 57 | 6. `npm run build` 编译 58 | 7. `npm start` 本地运行 59 | 60 | #### 后台 61 | 62 | 1. `git clone https://gitee.com/WindSnowLi/vue-admin-blog.git`或`git clone https://github.com/WindSnowLi/vue-admin-blog.git` 63 | 克隆项目到本地 64 | 2. `npm install` 安装依赖 65 | 3. `npm run dev` 使用模拟数据预览界面 66 | 4. 修改 `.env.production` 文件中的 `VUE_APP_BASE_API` 地址为后端 `api` 的地址 67 | 5. `npm run build:prod` 编译 68 | 6. `dist` 文件夹下的为编译好的文件,可放到 `http` 服务器下(可以使用 `npm` 安装 `http-server` )进行访问 69 | 70 | ### Docker集成启动 71 | 72 | 1. `git clone https://gitee.com/WindSnowLi/w-blog.git`或`git clone https://github.com/WindSnowLi/w-blog.git`克隆`w-blog`仓库至本地 73 | 2. `cd w-blog`切换进`w-blog`根目录 74 | 3. `sh ./step-1-clone.sh`克隆`w-blog-api`、`vue-ssr-blog`、`vue-admin-blog`仓库至根目录 75 | 4. 修改各项目相关配置 76 | 1. `w-blog-api`项目 77 | 1. 修改开发环境 `application-dev.yml` 和生产环境 `application-prod.yml` 中的数据库配置信息; 78 | 2. 修改 `redis.properties` 中的 `Redis` 相关信息; 79 | 3. 注: `knife4j` 只在开发环境中激活。 80 | 4. `redis可自行安装`,也可`docker-compose.yml`指定相关设置 81 | 2. `vue-ssr-blog`项目 82 | 1. 可修改 `config/sitemap.xml` 文件中的 `host` 地址,用于生成访问地图 83 | 2. 可修改 `nuxt.config.js` 中的端口号 84 | 3. 可修改 `package.json` 文件中的 `script` 中的 `BASE_URL` 来指定后端 `api` 地址 85 | 3. `vue-admin-blog`项目 86 | 1. 修改 `.env.production` 文件中的 `VUE_APP_BASE_API` 地址为后端 `api` 的地址 87 | 5. `sh ./step-2-build.sh`安装依赖生成相关文件 88 | 6. 修改`docker-compose.yml`的相关端口映射和文件夹映射 89 | 7. `docker-compose up -d`生成`docker镜像`并运行 90 | 91 | ## 界面展示 92 | 93 | ### 前台 94 | 95 | ![首页](./images/homepage.png) 96 | 97 |
98 | 99 | ![文章详情](./images/article-detail.png) 100 | 101 |
102 | 103 | ![友链](./images/links.png) 104 | 105 | ### 后台 106 | 107 | ![首页](./images/dashboard.png) 108 | 109 |
110 | 111 | ![创建文章](./images/create-art.png) 112 | 113 |
114 | 115 | ![管理文章](./images/man-art-list.png) 116 | 117 |
118 | 119 | ![文章列表](./images/art-list.png) 120 | 121 |
122 | 123 | ![友链管理](./images/man-links.png) 124 | 125 | ## License 126 | 127 | [MIT](https://github.com/WindSnowLi/w-blog/blob/master/LICENSE) 128 | 129 | Copyright (c) 2021 WindSnowLi 130 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | # 文件及文件夹映射自行设置 2 | # 描述 Compose 文件的版本信息 3 | version: "3.8" 4 | # 定义服务,可以多个 5 | services: 6 | api: # 服务名称 7 | build: 8 | context: ./api/src/main/docker 9 | depends_on: 10 | - redis 11 | container_name: w-blog-api # 容器名称,默认为"工程名称_服务条目名称_序号" 12 | command: sh -c "java -jar w-blog.jar --spring.profiles.active=\"prod\"" # 默认加载prod 13 | networks: 14 | my-network: 15 | # 指定IP 16 | ipv4_address: 172.20.0.80 17 | ports: # 宿主机与容器的端口映射关系 18 | - "9999:9000" # 左边宿主机端口:右边容器端口 19 | restart: always 20 | blog: 21 | build: 22 | context: ./blog 23 | depends_on: 24 | - api 25 | container_name: blog 26 | networks: 27 | my-network: 28 | # 指定IP 29 | ipv4_address: 172.20.0.81 30 | ports: 31 | - "3000:3000" 32 | restart: always 33 | admin: 34 | build: 35 | context: ./admin 36 | depends_on: 37 | - api 38 | container_name: admin 39 | networks: 40 | my-network: 41 | # 指定IP 42 | ipv4_address: 172.20.0.82 43 | ports: 44 | - "8000:80" 45 | restart: always 46 | redis: 47 | image: redis:latest 48 | container_name: redis 49 | command: 50 | - redis-server 51 | - --requirepass 52 | - "w-blog" 53 | - --bind 54 | - "172.20.0.83" 55 | networks: 56 | my-network: 57 | # 指定IP 58 | ipv4_address: 172.20.0.83 59 | restart: always 60 | networks: 61 | my-network: 62 | driver: bridge 63 | ipam: 64 | config: 65 | - subnet: 172.20.0.0/16 66 | gateway: 172.20.0.1 67 | -------------------------------------------------------------------------------- /images/art-list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WindSnowLi/w-blog/f7140c36e0bb092d4a3e272689adceacdfb45e62/images/art-list.png -------------------------------------------------------------------------------- /images/article-detail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WindSnowLi/w-blog/f7140c36e0bb092d4a3e272689adceacdfb45e62/images/article-detail.png -------------------------------------------------------------------------------- /images/create-art.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WindSnowLi/w-blog/f7140c36e0bb092d4a3e272689adceacdfb45e62/images/create-art.png -------------------------------------------------------------------------------- /images/dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WindSnowLi/w-blog/f7140c36e0bb092d4a3e272689adceacdfb45e62/images/dashboard.png -------------------------------------------------------------------------------- /images/homepage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WindSnowLi/w-blog/f7140c36e0bb092d4a3e272689adceacdfb45e62/images/homepage.png -------------------------------------------------------------------------------- /images/links.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WindSnowLi/w-blog/f7140c36e0bb092d4a3e272689adceacdfb45e62/images/links.png -------------------------------------------------------------------------------- /images/man-art-list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WindSnowLi/w-blog/f7140c36e0bb092d4a3e272689adceacdfb45e62/images/man-art-list.png -------------------------------------------------------------------------------- /images/man-links.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WindSnowLi/w-blog/f7140c36e0bb092d4a3e272689adceacdfb45e62/images/man-links.png -------------------------------------------------------------------------------- /step-1-clone.sh: -------------------------------------------------------------------------------- 1 | # !/bin/sh 2 | 3 | # 克隆api仓库 4 | git clone https://gitee.com/WindSnowLi/w-blog-api.git ./api 5 | 6 | # 克隆前台项目 7 | git clone https://gitee.com/WindSnowLi/vue-ssr-blog.git ./blog 8 | 9 | # 克隆后台项目 10 | git clone https://gitee.com/WindSnowLi/vue-admin-blog.git ./admin 11 | 12 | echo "请自行修改项目配置" -------------------------------------------------------------------------------- /step-2-build.sh: -------------------------------------------------------------------------------- 1 | # !/bin/sh 2 | cd ./api 3 | mvn package -Dmaven.test.skip=true 4 | cp ./target/w-blog-*.jar ./src/main/docker/ 5 | 6 | cd ../admin 7 | npm --registry=https://registry.npm.taobao.org install 8 | npm install 9 | npm run build:prod 10 | 11 | cd .. 12 | --------------------------------------------------------------------------------