项目打包部署流程(前后端本地打包部署)

本地部署

后端

首先打成jar包,尝试在本地运行

由于项目是maven父子工程 首先要把父项目进行install

配置好jdk环境(两套环境可选)这里使用的是jdk17

path中把java的环境置顶

查看当前jdk环境(保证正确的jdk环境)

在要运行的服务的pom.xml文件中添加相应的配置

xml 复制代码
<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>3.0.5</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                  <archive>
                      <manifest>
                          <mainClass>com.zmq.spzx.manager.ManagerApplication</mainClass>
                      </manifest>
                  </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

使用maven命令package 打包好服务 打成jar包

使用命令启动后端

前端

执行打包命令 npm run build 打包好前端

cmd 复制代码
npm run build

打包好的文件默认在dist目录

使用cmd命令进入该命令

使用node.js作为web服务器来运行这个项目 命令为

cmd 复制代码
npx http-server

执行这个命令后可能会需要下载相应的包 输入y确认即可

cmd 复制代码
D:\JavaProject\springcloud\spzx-admin\spzx-admin\dist>npx http-server
Need to install the following packages:
  http-server
Ok to proceed? (y) y
Starting up http-server, serving ./

http-server version: 14.1.1

http-server settings:
CORS: disabled
Cache: 3600 seconds
Connection Timeout: 120 seconds
Directory Listings: visible
AutoIndex: visible
Serve GZIP Files: false
Serve Brotli Files: false
Default File Extension: none

Available on:
  http://192.168.56.1:8080
  http://192.168.216.1:8080
  http://192.168.200.1:8080
  http://192.168.1.50:8080
  http://127.0.0.1:8080
  http://172.25.192.1:8080
Hit CTRL-C to stop the server

在浏览器就可以直接访问项目了 如图:

相关推荐
FungLeo6 小时前
成为全栈·React 管理后台篇·总复盘:从“接口能调通”到“后台值得使用”
前端·react.js·前端框架·项目复盘·成为全栈
EatFan6 小时前
Spring Boot 4 落地观察:从 yudao-cloud、matecloud、JPower 看国产脚手架的升级路线与迁移清单
java·spring boot·后端·spring cloud·微服务·后端开发·jdk 21
Maiko Star6 小时前
* LangChain 提示词模板详解:ChatPromptTemplate 的使用与高级特性
java·人工智能·langchain
Csvn7 小时前
并发模式:让渲染学会排队、插队和让路
前端
可乐鸡翅yeah_7 小时前
新手梳理:M3U8 线上问题,哪些是前端锅,哪些是后端锅
前端·ios·音视频·实时音视频·m3u8·音视频在线播放
Flynt7 小时前
Linear 用 1000 个 PR 换掉 styled-components,我写了 200 个按钮,把这笔账复现了一遍
前端·css·preact
波力海苔夹心脆6757 小时前
C# 序列化与反序列化详解:System.Text.Json、Newtonsoft.Json、XmlSerializer 用法、特性选项与安全实践
经验分享·后端·c#·json·.net
现任明教教主~8 小时前
Thinkphp站群蜘蛛池SaaS系统YanyvSEO含多用户/积分/六大引擎计费/易支付对接
java·开发语言·spring
JavaGuide8 小时前
NVIDIA 又开源了!这次给 AI Agent 加上权限管控
前端·后端