java-spring项目以及VUE项目的编译和部署

4 篇文章 0 订阅
1 篇文章 0 订阅

编译工具
IDEA2020.1.3
navicat15

xshell远程链接工具

xshell FTP

本地安装nodejs、yarn

centOS 7.x

centOS 安装JDK1.8

centOS安装nginx

nginx需配置,在etc/nginx/nginx.config 中把user 后的 nginx 改为root  

 

 

在etc/nginx/config.d/文件夹下创建文件web.conf , 写入

 

map $request_method $cors_method {
 OPTIONS 11;
 GET 1;
 POST 1;
 DELETE 1;
 PUT 1;
 default 0;
}

server {
    listen       8070;
    server_name  _;
    root         /root/;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
       if ($cors_method ~ '1') {
          add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE';
          add_header 'Access-Control-Allow-Origin' '*';
          add_header 'Access-Control-Allow-Headers' 'DNT,token,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
        }
        if ($cors_method = '11') {
          add_header 'Access-Control-Max-Age' 1728000;
          add_header 'Content-Type' 'text/plain; charset=UTF-8';
          add_header 'Content-Length' 0;
          return 204;
        }

    }


    location /api {
	proxy_set_header Host $host;
	#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_pass        http://127.0.0.1:8089/;
         if ($cors_method ~ '1') {
          add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE';
          add_header 'Access-Control-Allow-Origin' '*';
          add_header 'Access-Control-Allow-Headers' 'DNT,token,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
        }
        if ($cors_method = '11') {
          add_header 'Access-Control-Max-Age' 1728000;
          add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE';
          add_header 'Content-Type' 'text/plain; charset=UTF-8';
          add_header 'Access-Control-Allow-Headers' 'DNT,token,lang,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
          add_header 'Access-Control-Allow-Origin' '*';
          add_header 'Content-Length' 0;
          return 204;
        }

    }

    location /ws {
        proxy_pass http://127.0.0.1:8088/;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }


}

其中:

8070为VUE项目访问的端口,root 后 (此地为/root/)为dist文件夹目录,如果是连带dist文件夹copy过来,则改为/root/dist/

给dist文件夹777权限  chmod 777 dist/

启动nginx  ( systemctl start nginx )

 

项目
wetech(github上搜索)

 

编译命令

mvn clean package

生成的jar包在target文件夹下,通过ftp工具放入 服务器 root用户下,java -jar xxx.jar 运行jar包,端口默认8000/8080,记得关闭防火墙/通过端口

(如果出现找不到manifast之类的错误,以及出现找不到springApplication 的错误,删除以下代码)

VUE编译命令

yarn/npm run serve (本地运行,访问localhost:8060即可访问)

yarn/npm run build (target文件夹生成dist文件夹,通过ftp放入root目录下)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值