代码地址:https://github.com/hyblist/SpringBoot-Vue2.git
jdk1.8
mysql
node
navicat
idea
SpringBoot + Vue 1、前端环境搭建 1、Vue后台主体搭建地址:https://element.eleme.cn/#/zh-CN/component/installation
弹窗:https://layuion.com/docs/
docsify动态生成您的文档网站:https://docsify.js.org/#/
安装:
npm i element-ui -S搭建项目
1、vue-cli安装:
# 设置淘宝镜像 npm config set registry https://registry.npm.taobao.org # 安装vue-cli npm install -g @vue/cli
2、创建一个名为vue的工程
vue create vue
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Y75jaYg2-1656746400673)(springboot+vue.assets/image-20220626135443407.png)]
3、测试启动
cd vue npm run serve
4、项目结构
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-tCpKvhrY-1656746400675)(springboot+vue.assets/image-20220626135932147.png)]
5、安装element-ui
npm i element-ui -S
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
//{small}指定空间大小
Vue.use(ElementUI,{small})
6、修样式
新建goloable.css,并在main.js导入import ‘./assets/goloable.css’
html,body,div{
margin: 0;
padding: 0;
}
html,body{
height: 100%;
}
Home.vue
2、Vue后台整体完善(一) 1、设置整体页面100%导航一 分组一 选项1 选项2 选项3 选项4 选项4-1 导航二 分组一 选项1 选项2 选项3 选项4 选项4-1 导航三 分组一 选项1 选项2 选项3 选项4 选项4-1 王小虎 查看 新增 删除
goloable.css
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
App.vue
2、调整Home.vue
Home.vue 去除div,并设置
;并进行以下设置
3、Vue后台整体完善(二) 1、添加分页后台管理系统 导航一 分组一 选项1 选项2 选项3 选项4 选项4-1 导航二 分组一 选项1 选项2 选项3 选项4 选项4-1 导航三 分组一 选项1 选项2 选项3 选项4 选项4-1 王小虎 个人信息 退出
margin: 0;
padding: 0;
box-sizing: border-box;
}
.ml-5{
margin-left: 10px;
}
.ml-5{
margin-right: 5px;
}
.pd-10{
padding: 10px 0;
}
3、调整Home.vue
后台管理系统 导航一 分组一 选项1 选项2 选项3 选项4 选项4-1 导航二 分组一 选项1 选项2 选项3 选项4 选项4-1 导航三 分组一 选项1 选项2 选项3 王小虎 个人信息 退出 首页 用户管理 搜索 新增 批量删除 导入 导出 private Integer id; private String username; private String password; private String nickname; private String email; private String phone; private String address; } 编辑 删除
mapper(作用:与数据库交互):UserMapper.java
package com.yebin.springboot.mapper;
import com.yebin.springboot.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
//Mapper专门用来与数据库交互的
@Mapper //把UserMapper,注入bean
public interface UserMapper {
//@Select,mybatis的注解
@Select("select * from sys_user")
//泛型方法
List findAll();
}
controller: UserController.java
package com.yebin.springboot.controller;
import com.yebin.springboot.entity.User;
import com.yebin.springboot.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class UserController {
@Autowired //注入其他类的注解
private UserMapper userMapper;
@GetMapping("/")
private List index(){
return userMapper.findAll();
}
}
4、实现增删改查
安装mybatisx插件
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-depPnMzp-1656746400680)(springboot+vue.assets/image-20220627115620336.png)]
controller: UserController.java
package com.yebin.springboot.controller;
import com.yebin.springboot.entity.User;
import com.yebin.springboot.mapper.UserMapper;
import com.yebin.springboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/user")//统一加/user,如
public class UserController {
@Autowired //注入其他类的注解
private UserMapper userMapper;
@Autowired
private UserService userService;
@GetMapping
private List index(){
return userMapper.findAll();
}
@PostMapping //post请求
private Integer save(@RequestBody User user){ //@RequestBody可以把前端传来的对象转成java对象
//新增或更新
return userService.save(user);
}
@DeleteMapping("/{id}")
private Integer delete(@PathVariable Integer id){ //@PathVariable接收id
return userMapper.deleteById(id);
}
}
mapper(作用:与数据库交互):UserMapper.java
package com.yebin.springboot.mapper;
import com.yebin.springboot.entity.User;
import org.apache.ibatis.annotations.*;
import java.util.List;
//Mapper专门用来与数据库交互的
@Mapper //把UserMapper,注入bean
public interface UserMapper {
//@Select,mybatis的注解
@Select("select * from sys_user")
//泛型方法
List findAll();
@Insert("INSERT INTO sys_user(username,password,nickname,email,phone,address) VALUES(#{username},#{password},#{nickname},#{email},#{phone},#{address})")
int insert(User user);
// //这样写会导致,有些字段我本来不想更新的,但是却给了个null,所有要使用动态sql,在resources里面创建mapper文件夹,并新增User.xml(mybatis的xml)
// @Update("update sys_user set username = #{username}, password = #{password}, nickname= #{nickname}," +
// "email = #{email},phone = #{phone},address = #{address} where id = #{id}")
int update(User user);
@Delete("delete from sys_user where id = #{id}")
Integer deleteById(@Param("id") Integer id);//@Param("id")接收id
}
User.xml
-- 判断username是否为空 -- 密码不在这里修改 -- 注意要加","符号,要不然会报错 update sys_user username = #{username}, nickname = #{nickname}, email = #{email}, phone = #{phone}, address = #{address} id = #{id}
mybatis xml格式
配置mybatis application.yaml
# 应用服务 WEB 访问端口
server:
port: 9090
# 应用名称
spring:
application:
name: springboot
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/my_project?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8
username: root
password: 123456
#下面这些内容是为了让MyBatis映射
mybatis:
mapper-locations: classpath:mapper
public class CodeGenerator {
// //建议谨慎而行
// public static void main(String[] args) {
// generate();
// }
private static void generate(){
//在官网取代码:https://www.baomidou.com/ ——>代码生成器
FastAutoGenerator.create(
"jdbc:mysql://localhost:3306/my_project?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8",
"root", "123456") //数据库信息
.globalConfig(builder -> {
builder.author("ye_bin") // 设置作者
.enableSwagger() // 开启 swagger 模式
// .fileOverride() // 覆盖已生成文件,考虑清楚后就可以开启
.outputDir("F:\Project\springboot2\src\main\java\"); // 指定输出目录,一般指java
})
.packageConfig(builder -> {
builder.parent("com.yebin.springboot2") // 设置父包名
.moduleName(null) // 设置父包模块名,这样生成得连接就少一条""
.pathInfo(Collections.singletonMap(OutputFile.mapperXml, "F:\Project\springboot2\src\main\resources\mapper")); // 设置mapperXml生成路径
})
.strategyConfig(builder -> {
builder.entityBuilder().enableLombok(); //采用Lombok依赖
builder.mapperBuilder().enableMapperAnnotation().build();
//听说下面两个配置很关键,到时候看
builder.controllerBuilder().enableHyphenStyle() // 开启驼峰转连字符
.enableRestStyle(); // 开启生成@RestController 控制器
builder.addInclude("sys_user") // 设置需要生成的表名
.addTablePrefix("t_", "sys_"); // 设置过滤表前缀
})
// .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板
.execute();
}
}
3、下图位置可以复制模板去修改,也可以修改其他的
controller.java.vm
//自定义controller模板
package ${package.Controller};
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import $!{package.Service}.$!{table.serviceName};
import ${package.Entity}.${entity};
#if(${superControllerClassPackage})
import ${superControllerClassPackage};
#end
#if(${restControllerStyle})
@RestController
#else
@Controller
#end
@RequestMapping("#if(${package.ModuleName})/${package.ModuleName}#end/#if(${controllerMappingHyphenStyle})${controllerMappingHyphen}#else${table.entityPath}#end")
#if(${kotlin})
class ${table.controllerName}#if(${superControllerClass}) : ${superControllerClass}()#end
#else
#if(${superControllerClass})
public class ${table.controllerName} extends ${superControllerClass} {
#else
public class ${table.controllerName} {
#end
@Resource
private ${table.serviceName} ${table.entityPath}Service;
@PostMapping
public Boolean save(@RequestBody ${entity} ${table.entityPath}){
return ${table.entityPath}Service.saveOrUpdate(${table.entityPath});
}
@DeleteMapping("/{id}")
public Boolean delete(@PathVariable Integer id){
return ${table.entityPath}Service.removeById(id);
}
@GetMapping
public List<${entity}> findAll(){
return ${table.entityPath}Service.list();
}
@GetMapping("/{id}")
public List<${entity}> findOne(@PathVariable Integer id){
return ${table.entityPath}Service.list();
}
@GetMapping("/page")
public IPage<${entity}> findPage(
@RequestParam Integer pageNum,
@RequestParam Integer pageSize
){
QueryWrapper${entity}> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByDesc("id");
return ${table.entityPath}Service.page(new Page<>(pageNum,pageSize),queryWrapper);
}
}
}
#end
5、Vue使用路由
修改Home.vue文件改成Manage.vue
拆分Manage.vue
导入vuex
npm i vuex@3.6.2 -s
后面再补
6、springboot实现导入导出Hutool官网:https://www.hutool.cn/docs/#/
导入依赖
cn.hutool hutool-all 5.7.2 org.apache.poi poi-ooxml 3.17
导出
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-9RQCQmL3-1656746400682)(springboot+vue.assets/image-20220629224926854.png)]
User
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-poIyZxZ4-1656746400683)(springboot+vue.assets/image-20220629224809495.png)]
导入
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-9OIlTtXB-1656746400684)(springboot+vue.assets/image-20220629224837014.png)]
7、springboot和Vue实现用户登录登录页面
其他 div标签 1、div有什么作用div在html中有着分割的作用,分割与其他样式的作用,去设置页面的布局和样式,主要的作用就是包含一个区块,区块夹在div中,和前后代码隔开,形成一个区块。
2、div用法是一个块级元素。这意味着它的内容自动地开始一个新行。实际上,换行是固有的特定的格式表现。可以通过的 class style id 应用额外的样式。
java的泛型 1、泛型本质Java 泛型(generics)是 JDK 5 中引入的一个新特性, 泛型提供了编译时类型安全检测机制,该机制允许程序员在编译时检测到非法的类型。
泛型的本质是参数化类型,即给类型指定一个参数,然后在使用时再指定此参数具体的值,那样这个类型就可以在使用时决定了。这种参数类型可以用在类、接口和方法中,分别被称为泛型类、泛型接口、泛型方法。
//Integer本质:参数数化类型 ArrayList2、优点:intValues = new ArrayList ()
Java语言中引入泛型是一个较大的功能增强。不仅语言、类型系统和编译器有了较大的变化,以支持泛型,而且类库也进行了很大的改动,许多重要的类,比如集合框架,都已经成为泛型化的了。这带来了很多好处:
1、类型安全在没有泛型之前,从集合中读取到的每一个对象都必须进行类型转换,如果不小心插入了错误的类型对象,在运行时的转换处理就会出错。
//比如:没有泛型的情况下使用集合:
public static void noGeneric() {
ArrayList names = new ArrayList();
names.add("mikechen的互联网架构");
names.add(123); //编译正常
}
//有泛型的情况下使用集合:
public static void useGeneric() {
ArrayList names = new ArrayList<>();
names.add("mikechen的互联网架构");
names.add(123); //编译不通过
}
//有了泛型后,定义好的集合names在编译的时候add(123)就会编译不通过。
//相当于告诉编译器每个集合接收的对象类型是什么,编译器在编译期就会做类型检查,告知是否插入了错误类型的对象,使得程序更加安全,增强了程序的健壮性
2、消除强制类型转换
泛型的一个附带好处是,消除源代码中的许多强制类型转换,这使得代码更加可读,并且减少了出错机会。
//没有泛型的代码段需要强制转换:
List list = new ArrayList();
list.add("hello");
String s = (String) list.get(0);
//当重写为使用泛型时,代码不需要强制转换:
List list = new ArrayList();
list.add("hello");
String s = list.get(0); // no cast
3、更高的运行效率
在非泛型编程中,将筒单类型作为Object传递时会引起Boxing(装箱)和Unboxing(拆箱)操作,这两个过程都是具有很大开销的。引入泛型后,就不必进行Boxing和Unboxing操作了,所以运行效率相对较高,特别在对集合操作非常频繁的系统中,这个特点带来的性能提升更加明显。
泛型变量固定了类型,使用的时候就已经知道是值类型还是引用类型,避免了不必要的装箱、拆箱操作
//未使用泛型
object a=1;//由于是object类型,会自动进行装箱操作。
int b=(int)a;//强制转换,拆箱操作。这样一去一来,当次数多了以后会影响程序的运行效率。
//使用泛型之后
public static T GetValue(T a){
return a;
}
public static void Main(){
int b=GetValue(1);//使用这个方法的时候已经指定了类型是int,所以不会有装箱和拆箱的操作。
}
4、潜在的性能收益
3、如何使用泛型
泛型有三种使用方式,分别为:泛型类、泛型接口和泛型方法。
1、泛型类public class 类名 <泛型类型1,...> {
}
注意事项:泛型类型必须是引用类型(非基本数据类型)
定义泛型类,在类名后添加一对尖括号,并在尖括号中填写类型参数,参数可以有多个,多个参数使用逗号分隔:
public class GenericClass {}
当然,这个后面的参数类型也是有规范的,不能像上面一样随意,通常类型参数我们都使用大写的单个字母表示:
T:任意类型 type E:集合中元素的类型 element K:key-value形式 key V: key-value形式 value
示例代码:
public class GenericClass2、泛型接口{ private T value; public GenericClass(T value) { this.value = value; } public T getValue() { return value; } public void setValue(T value) { this.value = value; } }
//格式 public interface interfaceName
注意:
方法声明中定义的形参只能在该方法里使用,而接口、类声明中定义的类型形参则可以在整个接口、类中使用。当调用fun()方法时,根据传入的实际对象,编译器就会判断出类型形参T所代表的实际类型。
public interface GenericInterface{ void show(T value);} } public class StringShowImpl implements GenericInterface { @Override public void show(String value) { System.out.println(value); }} public class NumberShowImpl implements GenericInterface { @Override public void show(Integer value) { System.out.println(value); }}
注意:
//使用泛型的时候,前后定义的泛型类型必须保持一致,否则会出现编译异常: GenericInterface3、泛型方法genericInterface = new NumberShowImpl();//编译异常 //或者干脆不指定类型,那么 new 什么类型都是可以的: GenericInterface g1 = new NumberShowImpl(); GenericInterface g2 = new StringShowImpl();
泛型方法,是在调用方法的时候指明泛型的具体类型 。
//格式 publicT method Tt
示例
public T genercMethod(T t){
System.out.println(t.getClass());
System.out.println(t);
return t;
}
public static void main(String[] args) {
GenericsClassDemo genericString = new GenericsClassDemo("helloGeneric"); //这里的泛型跟下面调用的泛型方法可以不一样。
String str = genericString.genercMethod("hello");//传入的是String类型,返回的也是String类型
Integer i = genericString.genercMethod(123);//传入的是Integer类型,返回的也是Integer类型
}
//打印结果
//class java.lang.String
//hello
//class java.lang.Integer
//123
数据库三大范式是什么?
第一范式:每个列都不可以在拆分。
第二范式:在第一范式的基础上,非主键列完全依赖于逐渐,而不能是依赖于主键的一部分。
第三范式:在第二范式的基础上,非主键列只依赖于主键,不依赖于其他非主键。
在设计数据库结构的时候,要尽量遵守三范式,如果不遵守,必须有足够的理由。比如性能。事实上我们经常会为了性能而妥协数据库的设计。
@JsonIgnore
忽略某个字段不给前端展示
前端与后端做数据绑定后端提供一个接口:http://localhost:9090/user/page?pageNum=1&pageSize=2"
数据类型如下:
{
"total": 8,
"data": [
{
"id": 1,
"username": "admin",
"nickname": "管理员",
"email": "hyblist@163.com",
"phone": "17324070785",
"address": "广东茂名"
},
{
"id": 2,
"username": "xiaoming",
"nickname": "小明",
"email": "xiaoming@163.com",
"phone": "10086",
"address": "小明的家"
}
]
}
前端操作
2、二次确认弹窗(Popconfirm 气泡确认框)编辑 删除 取 消 确 定
编辑 删除
3、新增(绑定按钮弹窗)
新增按钮绑定handleAdd()方法
新增
批量删除
导入
导出
handleAdd()方法
//添加用户确认
handleAdd() {
this.dialogFormVisible = true
this.form = {}
},
弹窗的确认按钮绑定@click="saveUser"完成接口请求
//添加用户
saveUser() {
request.post("/user/", this.form).then(res => {
if (res) {
this.$message.success("新增成功")
this.load()
} else {
this.$message.error("新增失败")
}
});
this.dialogFormVisible = false
},
4、列表编辑(调用)
列表取row中数据:row打印出来是一个对象
编辑
绑定了@click="handleEdit(scope.row)"方法
//编辑用户
handleEdit(row) {
console.log(row)
this.form = row
this.dialogFormVisible = true //使新增的弹窗打开,数据是取编辑的
},
5、删除(调用二次弹窗的方法/或者不调用,如过不调用可以直接用@click=“delone(scope.row.id)”)
@confirm=“delone(scope.row.id)”
delone(id) {
request.delete("/user/" + id, this.form).then(res => {
if (res) {
this.$message.success("删除成功")
this.load()
} else {
this.$message.error("删除失败")
}
});
this.dialogFormVisible = false
},
6、批量删除
在data()里面添加字段
multipleSelection: []
使
handleSelectionChange()
,
//批量删除
handleSelectionChange(val) {
console.log(val)
this.multipleSelection = val
}
批量删除按钮绑定@click="delBatch"方法
新增
批量删除
导入
导出
@click="delBatch"方法
//批量删除按钮
delBatch() {
let ids = this.multipleSelection.map(v =>v.id) //[{},{},{}]=>[1,2,3]对象转换成数组
console.log(ids)
request.post("/user/del/batch", ids).then(res => { //这里的","很关键,不能写成"+",会很刺激
if (res) {
this.$message.success("批量删除成功")
this.load()
} else {
this.$message.error("批量删除失败")
}
console.log(res)
});
全选(Table 表格)
Exception 1、Invalid bound statement (not found): com.yebin.springboot.mapper.UserMapper.update
原因:没有配置mybatis的配置
#指定Mybatis的Mapper文件 mybatis: mapper-locations: classpath:mapper/*xml2、org.apache.ibatis.binding.BindingException: Parameter ‘pageNum’ not found. A
原因:@Param(“pageNum”)没有加@Param接收pageNum
@Select("select * from sys_user limit #{pageNum},#{pageSize}")
//泛型方法
List selectPage(@Param("pageNum")Integer pageNum,@Param("pageSize")Integer pageSize);
3、前端跨域问题
Access to fetch at ‘http://localhost:9090/user/page?pageNum=1&pageSize=2’ from origin ‘http://localhost:8080’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.
后端做调整:springboot跨域设置
package com.yebin.springboot.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
@Configuration
public class CorsConfig {
// 当前跨域请求最大有效时长。这里默认1天
private static final long MAX_AGE = 24 * 60 * 60;
@Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin("http://localhost:8080"); // 1 设置访问源地址
corsConfiguration.addAllowedHeader("*"); // 2 设置访问源请求头
corsConfiguration.addAllowedMethod("*"); // 3 设置访问源请求方法
corsConfiguration.setMaxAge(MAX_AGE);
source.registerCorsConfiguration("/**", corsConfiguration); // 4 对接口配置跨域设置
return new CorsFilter(source);
}
}
4、The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
原因:mysql服务没有启动
5、mybatis和mybatis-plus只能存在一个mybatis和mybatis-plus只能存在一个,要不然会打架,所以导入依赖只能存在其中一个
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 日志
true map-underscore-to-camel-case: true
6、 Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.
原因缺少一个
7、Uncaught TypeError: (0 , vue__WEBPACK_IMPORTED_MODULE_2__.reactive) is not a function原因vuex版本太高
npm i vuex@3.6.2 -s
if (res) {
this.$message.success("批量删除成功")
this.load()
} else {
this.$message.error("批量删除失败")
}
console.log(res)
});
全选(Table 表格) ```vueException 1、Invalid bound statement (not found): com.yebin.springboot.mapper.UserMapper.update
原因:没有配置mybatis的配置
#指定Mybatis的Mapper文件 mybatis: mapper-locations: classpath:mapper/*xml2、org.apache.ibatis.binding.BindingException: Parameter ‘pageNum’ not found. A
原因:@Param(“pageNum”)没有加@Param接收pageNum
@Select("select * from sys_user limit #{pageNum},#{pageSize}")
//泛型方法
List selectPage(@Param("pageNum")Integer pageNum,@Param("pageSize")Integer pageSize);
3、前端跨域问题
Access to fetch at ‘http://localhost:9090/user/page?pageNum=1&pageSize=2’ from origin ‘http://localhost:8080’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.
后端做调整:springboot跨域设置
package com.yebin.springboot.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
@Configuration
public class CorsConfig {
// 当前跨域请求最大有效时长。这里默认1天
private static final long MAX_AGE = 24 * 60 * 60;
@Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin("http://localhost:8080"); // 1 设置访问源地址
corsConfiguration.addAllowedHeader("*"); // 2 设置访问源请求头
corsConfiguration.addAllowedMethod("*"); // 3 设置访问源请求方法
corsConfiguration.setMaxAge(MAX_AGE);
source.registerCorsConfiguration("/**", corsConfiguration); // 4 对接口配置跨域设置
return new CorsFilter(source);
}
}
4、The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
原因:mysql服务没有启动
5、mybatis和mybatis-plus只能存在一个mybatis和mybatis-plus只能存在一个,要不然会打架,所以导入依赖只能存在其中一个
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 日志
true map-underscore-to-camel-case: true
6、 Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.
原因缺少一个
7、Uncaught TypeError: (0 , vue__WEBPACK_IMPORTED_MODULE_2__.reactive) is not a function原因vuex版本太高
npm i vuex@3.6.2 -s



