Files
hcframe-doc/docs/01.指南/03.打包部署.md
2021-02-03 17:01:33 +08:00

76 lines
1.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: 打包部署
date: 2021-02-03 09:26:32
permalink: /pages/6fe261/
---
# 打包部署
::: tip
框架提供两种部署方式,第一种为前后端一起打包部署,第二种为前后端分离打包部署。
:::
## 前后端一起部署
1. 修改生产环境Base url文件 `./.env.production`
``` properties
VUE_APP_BASE_API = './'
```
2. 进入前端目录执行打包命令
``` bash
cd common-web
yarn build:prod
```
3. 执行完成后前端项目将生产dist文件夹
![dist](https://cdn.jsdelivr.net/gh/taixingyiji/image_store@main/blog/20210203155236.png)
4. 打开dist目录将除了 `index.html` 的文件全部考入后端项目 `src>main>resources>static` 目录下
,将 `index.html` 文件考入到 `src>main>resources>templates` 目录下
![static](https://cdn.jsdelivr.net/gh/taixingyiji/image_store@main/blog/20210203155255.png)
5. 进入后台代码目录执行maven打包命令
``` bash
cd common/
mvn clean package
```
6. 将生成的war包上传到tomcat等服务器进行部署。
## 前后端分离部署
1. 修改生产环境Base url文件 `./.env.production`
``` properties
# Base api此处填写后台请求的地址及端口及路径
VUE_APP_BASE_API = 'http://192.168.1.123:8080/common'
```
2. 进入前端目录执行打包命令
``` bash
cd common-web
yarn build:prod
```
3. 执行完成后前端项目将生产dist文件夹
![dist](https://cdn.jsdelivr.net/gh/taixingyiji/image_store@main/blog/20210203155236.png)
4. 将生成的dist文件夹里面内容上传至Nginx或Apache静态服务器
5. 进入后台代码目录执行maven打包命令
``` bash
mvn clean package
```
6. 将生成的war包上传到tomcat等服务器进行部署。