参考视频
【实战】基于SpringBoot+Vue开发的前后端分离博客项目完整教学_哔哩哔哩_bilibili
我自己上传的github,基本就是copy的,https://github.com/CodePpoi/vueblog-learn
springboot项目搭建
首先建立一个spingboot项目,SQL选择mysql driver,Spring web,Lombok,创建两张表m_user,m_blog,脚本如下:
然后使用Code Generator生成对应的dao层, code generator代码如下,记得改mysql 账号密码,以及包名:
修改user controler,并访问localhost:8080校验
生成result类,统一返回结果,方便交给前端处理
shiro编码,这个主要是处理 header的authorization字段,涉及create token, jwtfilter,相关,jwt filter覆写两个方法
不要用controler和getmappling,有问题,要用rest controller和requsetmapping
filterMap 里面用authc会报404,因为没有登录,所以需要
filterMap.put("/**", "jwt")
Vue项目搭建及运行
参考: https://blog.csdn.net/newbaby2012/article/details/116406086
项目运行,命令: npm run serve
启动mysql
mysql -u root -p 你的密码
或者 net start mysql
修改配置文件application-default.yml
# DataSource Config
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/vueblog?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=Asia/Shanghai
username: root
password: root
shiro-redis:
enabled: true
redis-manager:
host: 127.0.0.1:6379
数据库连不上我日,算了就这吧,反正能成就行