日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > vue >内容正文

vue

在服务器上打包部署springboot+vue的项目(一)启动tomcat后打开浏览器点击登录无反应 页面空白问题

發布時間:2024/9/30 vue 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 在服务器上打包部署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

module.exports = {// 項目部署的基礎路徑// 我們默認假設你的應用將會部署在域名的根部,// 比如 https://www.my-app.com/// 如果你的應用時部署在一個子路徑下,那么你需要在這里// 指定子路徑。比如,如果你的應用部署在// https://www.foobar.com/my-app/// 那么將這個值改為 `/my-app/`/*這個是我存放在github在線預覽的Reader項目*/// 將構建好的文件輸出到哪里(或者說將編譯的文件)outputDir: 'dist',// 放置靜態資源的地方 (js/css/img/font/...)assetsDir: 'static',// 用于多頁配置,默認是 undefinedpages: {index: {// 入口文件entry: 'src/main.js',  /*這個是根入口文件*/// 模板文件template: 'public/index.html',// 輸出文件filename: 'index.html',// 頁面titletitle: 'Index Page'},// 簡寫格式// 模板文件默認是 `public/subpage.html`// 如果不存在,就是 `public/index.html`.// 輸出文件默認是 `subpage.html`.subpage: 'src/main.js'    /*注意這個是*/},// 是否在保存的時候使用 `eslint-loader` 進行檢查。// 有效的值:`ture` | `false` | `"error"`// 當設置為 `"error"` 時,檢查出的錯誤會觸發編譯失敗。lintOnSave: true,// 使用帶有瀏覽器內編譯器的完整構建版本// 查閱 https://cn.vuejs.org/v2/guide/installation.html#運行時-編譯器-vs-只包含運行時runtimeCompiler: false,// babel-loader 默認會跳過 node_modules 依賴。// 通過這個選項可以顯式轉譯一個依賴。transpileDependencies: [/* string or regex */],// 是否為生產環境構建生成 source map?productionSourceMap: true,// 調整內部的 webpack 配置。// 查閱 https://github.com/vuejs/vue-docs-zh-cn/blob/master/vue-cli/webpack.mdchainWebpack: () => {},configureWebpack: () => {},// CSS 相關選項css: {// 將組件內的 CSS 提取到一個單獨的 CSS 文件 (只用在生產環境中)// 也可以是一個傳遞給 `extract-text-webpack-plugin` 的選項對象extract: true,// 是否開啟 CSS source map?sourceMap: false,// 為預處理器的 loader 傳遞自定義選項。比如傳遞給// sass-loader 時,使用 `{ sass: { ... } }`。loaderOptions: {},// 為所有的 CSS 及其預處理文件開啟 CSS Modules。// 這個選項不會影響 `*.vue` 文件。modules: false},// 在生產環境下為 Babel 和 TypeScript 使用 `thread-loader`// 在多核機器下會默認開啟。parallel: require('os').cpus().length > 1,// PWA 插件的選項。// 查閱 https://github.com/vuejs/vue-cli/tree/dev/packages/@vue/cli-plugin-pwapwa: {},// 配置 webpack-dev-server 行為。devServer: {open: process.platform === 'darwin',host: '0.0.0.0',port: 8080,https: false,hotOnly: false,// 查閱 https://github.com/vuejs/vue-docs-zh-cn/blob/master/vue-cli/cli-service.md#配置代理proxy:{'/api':{target:'http://localhost:9000',changeOrigin:true,secure:false,// ws: true,pathRewrite:{'^/api':'/static/mock'// 請求數據路徑別名,這里是注意將static/mock放入public文件夾}}},before: app => {}},// 三方插件的選項pluginOptions: {// ...} }

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

proxy:{'/api':{target:'http://localhost:9000',changeOrigin:true,secure:false,// ws: true,pathRewrite:{'^/api':'/static/mock'// 請求數據路徑別名,這里是注意將static/mock放入public文件夾}}},

(后端springboot的application.yml中端口是9000:

server:
port: 9000
)

再次輸入npm run build prod
粘貼index.html和static

2.一定要記得啟動jar包 !!!!!
啟動jar的方式是雙擊這個文件:

現在點擊登錄有反應了:

下一個問題是數據庫的數據在服務器上還顯示不出來,留待解決。

總結

以上是生活随笔為你收集整理的在服务器上打包部署springboot+vue的项目(一)启动tomcat后打开浏览器点击登录无反应 页面空白问题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。