- 需求:
无
- 实现功能:
实现一个前后端分离的项目模板,以供更好的开发项目(主要基于上次搭建的vue项目,实现通过接口访问后台实现查询后台数据库用户信息的简易版Demo)
- 环境:
idea 2021.6
mysql 8.0
vue环境见上节(离线安装模板)
- 可能相关问题描述:
①项目启动中前后端端口不一致问题的解决方法?
1) 通过配置访问Vue后端的接口地址实现,在build/index.js中proxyTable中加入如下代码:
proxyTable: { '/api': { target: 'http://localhost:8081',//要访问的后端接口 changeOrigin: true, pathRewrite: { '^/api': '/' //这句话的意思是用'/api来代替http://localhost:8081/' // '^/api': '/' '用/api来代替http://localhost:8081' } } },
2) 当后台引入SpringSecurity后,如果不进行任何配置,SpringSecurity自带有登录页面,会出现跨域跳转路径被/login拦截导致无法登录问题。(以请求localhost:8081/api/user为例)
以上图为例,springBoot引入如下pom文件后不做任何配置,出现无法跨域问题
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency>删除pom后