在服务器上打包部署springboot+vue的项目(一)启动tomcat后打开浏览器点击登录无反应 页面空白问题
先記錄查看與關閉端口的命令:
netstat -ano|findstr “8080”
taskkill /pid 5588 /f
打開某個端口:
netsh firewall add portopening protocol = TCP port = 8080 name = “Open8080” mode = Enable
查看進程: services.msc
配置
購買的騰訊輕量應用服務器,27R 3個月 內存2G 硬盤64G
ping 自己的ip地址:
什么是輕量應用服務器 Lighthouse? 輕量應用服務器
Lighthouse
是一種易于使用和管理、適合承載輕量級業務負載的云服務器,能幫助個人和企業在云端快速構建網站、博客、電商、論壇等各類應用以及開發測試環境,并提供應用部署、配置和管理的全流程一站式服務,極大提升構建應用的體驗,是您使用騰訊云的最佳入門途徑。
輕量應用服務器與云服務器 CVM 的區別是什么? 輕量應用服務器 Lighthouse 對比云服務器
CVM,輕量應用服務器更加簡單易用,融合多款云產品和應用服務能力,簡化了傳統云服務器的高階概念及功能,幫助開發者更加專注于業務邏輯與創新。詳情請參見
產品對比。
首先買了以后可以設置Administrator的密碼,然后可以從這里進入
進入服務器的圖形界面,也可以從自己電腦遠程進入(輸入IP 用戶名和密碼)
自己的項目前端是vue3.0框架,后端有springboot和flask(后者用于深度學習),由于接觸計網的知識不多,所以對于服務器、http、ftp等協議方面還只是粗略了解,望指正。
解決tomcat啟動中文亂碼:
修改logging.properties
改為GBK
打包前端:
前端
新建vue.config.js
config目錄下的index.js
'use strict' // Template version: 1.2.6 // see http://vuejs-templates.github.io/webpack for documentation.const path = require('path')module.exports = {dev: {// PathsassetsSubDirectory: 'static',assetsPublicPath: './',proxyTable: {},// Various Dev Server settingshost: '121.5.227.176', // can be overwritten by process.env.HOSTport: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determinedautoOpenBrowser: true,errorOverlay: true,notifyOnErrors: false,poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-// Use Eslint Loader?// If true, your code will be linted during bundling and// linting errors and warnings will be shown in the console.useEslint: false,// If true, eslint errors and warnings will also be shown in the error overlay// in the browser.showEslintErrorsInOverlay: false,/*** Source Maps*/// https://webpack.js.org/configuration/devtool/#developmentdevtool: 'cheap-source-map',// CSS Sourcemaps off by default because relative paths are "buggy"// with this option, according to the CSS-Loader README// (https://github.com/webpack/css-loader#sourcemaps)// In our experience, they generally work as expected,// just be aware of this issue when enabling this option.cssSourceMap: false},build: {// Template for index.htmlindex: path.resolve(__dirname, '../dist/index.html'),// PathsassetsRoot: path.resolve(__dirname, '../dist'),assetsSubDirectory: 'static',/*** You can set by youself according to actual condition* You will need to set this if you plan to deploy your site under a sub path,* for example GitHub pages. If you plan to deploy your site to https://foo.github.io/bar/,* then assetsPublicPath should be set to "/bar/".* In most cases please use '/' !!!*/assetsPublicPath: './',/*** Source Maps*/productionSourceMap: false,// https://webpack.js.org/configuration/devtool/#productiondevtool: 'source-map',// Gzip off by default as many popular static hosts such as// Surge or Netlify already gzip all static assets for you.// Before setting to `true`, make sure to:// npm install --save-dev compression-webpack-pluginproductionGzip: false,productionGzipExtensions: ['js', 'css'],// Run the build command with an extra argument to// View the bundle analyzer report after build finishes:// `npm run build --report`// Set to `true` or `false` to always turn it on or offbundleAnalyzerReport: process.env.npm_config_report || false,// `npm run build:prod --generate_report`generateAnalyzerReport: process.env.npm_config_generate_report || false} }其實還不明白這兩個的區別。
輸入:
npm run build prod
生成dist
后端
jar包:
打開后端項目(IDEA)先點擊clean再點擊package
生成
發現 問題:(1)服務器的瀏覽器輸入8080一片空白,
解決:只把dist復制到了ROOT目錄下,但應該把index.html和static復制到下面才行,重新改為:
打開8080顯示登陸頁面:
問題(2)點擊登錄沒反應,進不去
解決:
1.
修改vue.config.js
(后端springboot的application.yml中端口是9000:
server:
port: 9000
)
再次輸入npm run build prod
粘貼index.html和static
2.一定要記得啟動jar包 !!!!!
啟動jar的方式是雙擊這個文件:
現在點擊登錄有反應了:
下一個問題是數據庫的數據在服務器上還顯示不出來,留待解決。
總結
以上是生活随笔為你收集整理的在服务器上打包部署springboot+vue的项目(一)启动tomcat后打开浏览器点击登录无反应 页面空白问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【笔记】JAVA中的泛型和反射
- 下一篇: 在服务器上打包部署springboot+