springboot+vue本地部署

最近完成项目,需要部署到本地,期间遇到了一些问题,最后写下流程以作记录。

springboot打包

这块的内容较为简单一般为在pom.xml中加入

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>

让项目在打包时,后续出现"xx.jar中没有主清单属性的解决办法"。

之后直接点击图中的package就可完成后端打包

此时就可在对应的文件夹中看到生成的包

然后只需要在目录栏中输入cmd,命令提示符进入对应的目录,

java -jar xxx.jar (可打出第一个字母tab补全)

至此后端项目就完成了

前端vue部署

首先在项目根目录下创建vue.config.js文件

  publicPath: './', // 部署应用包时的基本 url
outputDir: 'dist', // build 构建文件目录
assetsDir: 'static', // 静态资源目录
lintOnSave: process.env.NODE_ENV === 'development', // 仅在开发模式下进行 eslint 检测代码
productionSourceMap: false, // 禁用生产环境的 source map
runtimeCompiler: true, // 是否运行时组件中使用 template
devServer: {
host: '0.0.0.0', // 默认是 localhost,可不配置
port: 8000, // 配置端口号
open: true, // 启动是否打开浏览器
overlay: { // 是否在浏览器上显示编译的 errors 或 warnings
warnings: false,
errors: true
},
proxy: {
'/api': { // 被代理的接口名
target: 'http://localhost:8080', // url地址
changeOrigin: true, // 发送请求头中 host 是否设置成 target
pathRewrite: { // 重定向
'^/api': ''
}
}
}
},
  • 查看路由中(router/index.js)是否使用history,是的话修改为hash。或者将mode直接注掉,因为默认使用hash

查看路由中(router/index.js)是否使用history,是的话修改为hash。或者将mode直接注掉,因为默认使用hash。

然后再次使用npm run build进行打包就会出现dist文件夹,已经其中静态文件会放置到static中。

到此打包已经结束。

部署nginx

  • 首先安装nignx,具体可搜博客

  • 然后将dish中的内容复制到nginx目录下的html文件夹下

  • 最后更改nginx.conf

#user  nobody;
worker_processes 1; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections 1024;
} http {
include mime.types;
default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout 65; #gzip on; server {
listen 8001;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main;
root "E:\ideaworkplace\AVIC\AVICTest\vue-admin\dist";
location / {
#root html;
#index index.html index.htm;
try_files $uri /index.html;
}
location ^~ /api/ {
proxy_pass http://localhost:8080/; #后端服务真实地址
}
# location /api {
# proxy_pass http://localhost:8080;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection 'upgrade';
# proxy_set-header Host $host;
# proxy_cache_bypass $http_update; # }
#error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }
  • 然后直接循行Nginx.exe ,或者start nginx都可,屏幕会闪烁以下,表示运行成功
  • 然后就能访问

小结:由于是第一次部署前后端分离项目,期间遇到很多问题,一般解决思路通过程序和打完的包互相访问(4种)试出哪个有问题,然后对应的解决。

springboot+vue本地部署的更多相关文章

  1. SpringBoot + Vue + nginx项目部署(零基础带你部署)

    一.环境.工具 jdk1.8 maven spring-boot idea VSVode vue 百度网盘(vue+springboot+nginx源码): 链接:https://pan.baidu. ...

  2. 使用Docker部署Spring-Boot+Vue博客系统

    在今年年初的时候,完成了自己的个Fame博客系统的实现,当时也做了一篇博文Spring-boot+Vue = Fame 写blog的一次小结作为记录和介绍.从完成实现到现在,也断断续续的根据实际的使用 ...

  3. springboot+vue前后端分离,nginx代理配置 tomcat 部署war包详细配置

    1.做一个小系统,使用了springboot+vue 基础框架参考这哥们的,直接拿过来用,链接https://github.com/smallsnail-wh/interest 前期的开发环境搭建就不 ...

  4. vue + ArcGIS 地图应用系列一:arcgis api本地部署(开发环境)

    封面 1. 下载 ArcGIS API for JavaScript 官网地址: https://developers.arcgis.com/javascript/3/ 下载地址:http://lin ...

  5. SpringBoot+Vue前后端分离,使用SpringSecurity完美处理权限问题(一)

    当前后端分离时,权限问题的处理也和我们传统的处理方式有一点差异. 笔者前几天刚好在负责一个项目的权限管理模块,现在权限管理模块已经做完了,我想通过5-6篇文章,来介绍一下项目中遇到的问题以及我的解决方 ...

  6. SpringBoot+Vue前后端分离,使用SpringSecurity完美处理权限问题

    原文链接:https://segmentfault.com/a/1190000012879279 当前后端分离时,权限问题的处理也和我们传统的处理方式有一点差异.笔者前几天刚好在负责一个项目的权限管理 ...

  7. SpringBoot + Vue + ElementUI 实现后台管理系统模板 -- 后端篇(一): 搭建基本环境、整合 Swagger、MyBatisPlus、JSR303 以及国际化操作

    相关 (1) 相关博文地址: SpringBoot + Vue + ElementUI 实现后台管理系统模板 -- 前端篇(一):搭建基本环境:https://www.cnblogs.com/l-y- ...

  8. SpringBoot工程+热部署进行远程调试

    本文转载自:https://blog.csdn.net/qq_31868349/article/details/78553901 SpringBoot工程+热部署进行远程调试 本地端添加配置 在pom ...

  9. Vue项目部署问题及解决方案

    Vue项目部署问题及解决方案 Vue-Router 有两种模式,默认是 hash 模式,另外一种是 history 模式. hash:也就是地址栏里的 # 符号.比如 http://www.examp ...

  10. Vue项目部署遇到的问题及解决方案

    写在前面 Vue-Router 有两种模式,默认是 hash 模式,另外一种是 history 模式. hash:也就是地址栏里的 # 符号.比如 http://www.example/#/hello ...

随机推荐

  1. Windows 11 调整工具 TweakNow WinSecret for Windows 11 3.2.0 中文汉化版

    Windows 11 调整工具 TweakNow WinSecret for Windows 11 中文版由大眼仔旭(www.dayanzai.me)发布.适用于 Windows 11 的 Tweak ...

  2. React Developer插件报错Cannot read properties of undefined (reading ‘forEach‘)

    安装了3.6的版本React Developer 启用插件后 报错 解决 https://www.crx4chrome.com/crx/3068/ 下载 下载好后,直接拖入扩展程序中

  3. idea字体的大小设置

    idea字体大小设置 两个方法,滚轮.固定大小设置 固定字体大小 file--settings--editor--font--size 修改为需要大小字号,例如20,点击ok 菜单栏的大小设置也差不多 ...

  4. dll帮助类

    项目中有很多时候用到外部dll,调用的时候如果用静态调用,程序exe目录下有很多dll,看起来很乱,不利于后续维护:动态调用可以把dll放在想放的文件夹内,但是如果一个dll要用到的函数很多,动态调用 ...

  5. ARM的发展史以及架构解析

    本文从ARM的发展历史着手,以S3C2440为例与51单片机进行对比分析,详细解析了ARM架构. 先来谈一下ARM的发展史:1978年12月5日,物理学家Hermann Hauser和工程师Chris ...

  6. 代替宝塔的webmin搭建

    webmin官网 对于IBM的服务器,cpu架构不同于常见的x86或aarch64,部分第三方软件是无法正常安装的,比如大名鼎鼎的宝塔面板,对于像我一样的新手很不友好,这里分享一款代替宝塔的web管理 ...

  7. element-ui学习之-------input表单验证【各种情况总结】

    1.非必填,正整数 2.非0开头正整数

  8. zabbix编译安装,安装mysql数据库:configure: error: Not found mysqlclient library

    在编译时,可能会出现题目中所示的错误,可以通过安装mysql-devel这个库解决: # yum install mysql-devel 注:如果出现"configure: error : ...

  9. 看到项目中的DateTimeFormat和JsonFormat就头大

    刚来这家公司的时候, 发现很多同事还在用这种方式写代码 当时以为是偶然, 刚才在群里发现还有好多人在交流应当加哪些注解, 声明时区问题. 当写一个东西感到麻烦的时候, 那么大概率是有低成本的更优解的 ...

  10. 2022-11-22学习内容-Client端代码编写-数据删除

    1.Client端代码编写 1.1activity_content_write.xml <?xml version="1.0" encoding="utf-8&qu ...