您的位置:首页 > Web前端 > Vue.js

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

2020-07-16 04:55 447 查看

项目地址: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

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐