栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

SpringBoot+Vue搭建

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SpringBoot+Vue搭建

npm配置镜像

查看

npm config get registry

设置淘宝

npm config set registry=https://registry.npm.taobao.org
Vue脚手架安装
npm install -g @vue/cli@4.5.15
安装element-ui包,在终端执行以下命令
npm i element-ui
在main.js中写入以下内容
import Vue from 'vue';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App.vue';

Vue.use(ElementUI);

new Vue({
  el: '#app',
  render: h => h(App)
});
前后端分离解决跨越问题

在Controller类上加上如下注解

@CrossOrigin(origins = {"*", "null"})

安装axios
npm i axios
基本使用
import axios from 'axios'

axios.get('http://localhost:8000/students').then(
	response => {
		console.log(response.data);
	},
	error =>{
		console.log(error.massage);
	}
)
后端配置文件 pom.xml


    4.0.0

    org.example
    mybatis_plus01
    1.0-SNAPSHOT

    
        8
        8
    
    
        org.springframework.boot
        spring-boot-starter-parent
        2.6.7
        
    
    
        
            org.springframework.boot
            spring-boot-starter
        
        
            org.springframework.boot
            spring-boot-starter-test
            test
        
        
            org.springframework.boot
            spring-boot-starter-web
        
        
            com.baomidou
            mybatis-plus-boot-starter
            3.5.1
        
        
            org.projectlombok
            lombok
            true
        
        
            mysql
            mysql-connector-java
            runtime
        
        
            com.google.code.gson
            gson
            2.8.5
        
    

application.yaml
spring:
  datasource:
    username: demo
    password: 'demo'
    url: jdbc:mysql://127.0.0.1:3306/demo?characterEncoding=UTF-8&serverTimezone=UTC
    driver-class-name: com.mysql.cj.jdbc.Driver
启动类
package org.example;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@MapperScan("org.example.mapper")
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/959409.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号