springboot+vue+ElementUi项目实例,部署到云服务器上

4 篇文章 0 订阅
3 篇文章 0 订阅

项目地址:https://e.coding.net/dabfdebfhui/springbootvue.git
SpringBoot(端口号:8081)
1.导入mysql数据库
2.代码生成器生成实体类与Mapper文件
3.搭建springBoot+mybatis+Swagger项目
创建项目过程中开始可以不选,进入项目后在pom.xml文件中添加

Vue(端口号:8080)
1.使用Vue cli脚手架创建Vue项目

1.下载node.js
2.切换npm源为天猫
3.全局安装vue-cli
npm install --global vue-cli
4.生成项目
vue init webpack 项目名称
5.启动命令npm run dev
6.localhost:8080


启动
npm run dev

打包
npm run build


参考网址
https://blog.csdn.net/mentalitys/article/details/93845973

2.安装Axios

**1.安装**
npm install axios -s

**2.main.js引入并设置**

import axios from 'axios';

// var axios = require('axios')
axios.defaults.baseURL = 'http://localhost:8081/NingAcc'
// 将API方法绑定到全局
Vue.prototype.$axios = axios
Vue.config.productionTip = false

3.方法使用
moneyData() {
      this.$axios.get("/findAll", { query: { } }).then(res => {
        this.moneyLists = res || [];
        console.log(this.moneyLists);
        console.log("moneyList---------->" + this.moneyLists);
        console.log("moneyList-------->" + this.moneyListT);
      });
    }

3.安装ElementUI

1.进入项目目录下安装elementUI的依赖包
npm i element-ui -S
2.在main.js中加入
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI)

参考网址
https://blog.csdn.net/mentalitys/article/details/93845973

4.安装Route
具体看项目

1.导航栏route跳转必须添加
:default-active="this.$route.path" router


如:
<el-menu  :default-active="this.$route.path" router class="el-menu-demo" mode="horizontal" @select="handleSelect"
      background-color="#545c64" text-color="#fff" active-text-color="#ffd04b">

Springboot与Vue集成jar包
(1)vue

1.设置后端代理
在根目录的config目录下的index.js中设置
proxyTable: {
      '/': {
        target: 'http://localhost:8081',
        changeOrigin: true,
        pathRewrite: {
            '^/': ''
        }
      }
    },
2.打包
npm run build
3.集成
在根目录的dist目录中,存在Vue打的包,全部复制放置于springboot项目的resources下的static目录下。

(2)springboot
1.左上角clean
2.左上角package,生成target文件,注意:检查mapping是否存在
3.在target目录下打开shell窗口,运行java -jar xxxxxx.jar,浏览器访问localhost:8081。

jar包部署到云服务器上
链接:https://blog.csdn.net/weixin_45573378/article/details/106861562

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值