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. 8.class 类

    一.基础语法 class 类名 { } 二.类的属性 基础语法: class 类名 { 属性名: 数据类型 = 属性值; contructor(形参名: 数据类型) { this.属性名 = 属性值; ...

  2. enzyme文档

    Enzyme是一个用于React的JavaScript测试实用程序,它使得更容易断言,操作和遍历您的React组件的输出,它模拟了jQuery的API,非常直观,易于使用和学习. 整理相当API为中文 ...

  3. (0501)phase机制

    (1)启动seq: (2) 0312:

  4. Docker CLI docker buildx bake 常用命令

    Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的镜像中,然后发布到任何流行的 Linux或Windows操作系统的机器上,也可以实现虚拟化.Docker是内核 ...

  5. ctfshow web入门 命令执行 37-39

    37-39 基于 GET 传参的 include() 38.39 是 37 的变种 分析 伪协议常用于文件包含漏洞中 文件包含函数有:include.include_once.require.requ ...

  6. 超强大的PS汉化插件Specs 一键尺寸标注

    尺寸标注是大多数设计师必不可少的细节工作,特别是在一些特定的设计图中,标注至关重要.大部分设计大大都直接用CAD标注,其实借助插件,PS也是完全可以搞定常见的尺寸标注的. 插件介绍 这是一款超级强大的 ...

  7. make vscode portable together with its extensions

    0. the goal make vscode poratable together with its extensions, so that the offline pc could make us ...

  8. 最小化安装debian10&gnome最小化安装

    直到后面配置网络源之前都是断网安装,因为debian security好像总是要去总源找点东西,所以即便你选择国内源甚至不选择网络源安装,依然会莫名 的失败. I. 最小化安装debian10(用ro ...

  9. GoogleAdMob

    写在最开始==================>一定要确定好中介和GoogleAdMob的版本对应关系 由于GoogleAdMob对接的官方文档是叫你去下载旧版的SDK,然后就很容易就弄混了版本 ...

  10. NSQ(7)-nsq存在的问题

    nsq存在的缺陷 部署的难度 ​ nsq提供了一种消费者端进行服务发现的模型,所以无需告诉消费者去哪寻找对于的主题(Topic)在哪个nsqd实例上. ​ 然而,它并没有提供一种方案去解决一个生产者应 ...