前言
最近学习了一个18年黑马springboot整合shiro的demo,比之前看的shiro学习视频感觉更容易理解一些,故作分享。之前在尚硅谷看过的视频,是shiro与spring整合,用的是xml配置方式,跟现在流行使用springboot的开发方式略有不同,因此黑马的此视频更容易让人看懂。当然,黑马跟尚硅谷相比,前者符合实际容易理解,后者涉及到更多shiro的功能,建议都看。
ps:本文主要分享的是18年黑马springboot整合shiro的视频
介绍
本demo除了springboot整合shiro外,数据库用的是mysql,操作数据库用的是mybatis,前端页面用的是thymeleaf
项目目录
(common中的MyShiroResult是博主自行添加的,视频里并没用到,请大家自行忽略)
遇到的坑
接下来谈谈敲这个demo时遇到的坑,有关数据库方面的
可能是mysql更新换代,导致了跟以往有一些差别
一是mysql的驱动名变了:从com.mysql.jdbc.Driver变成com.mysql.cj.jdbc.Driver,否则在程序操作数据库时会报Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
二是要在url后面配置serverTimezone属性,在url链接后面加上serverTimezone=UTC,否则在程序操作数据库时会报java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone.
心得
本demo是需要自己编写前端页面的,但实际开发往往是前后端分离,如何将shiro用到实际开发上,还得慢慢琢磨
分享
附上18年黑马springboot整合shiro视频:
链接:https://pan.baidu.com/s/16WZ3-xp0lHqWnxlaKSnl1A
提取码:0v6r
视频总时长:约2小时
附上github项目(18年黑马)链接:
https:https://github.com/Kanject-Lang/springboot-shiro-.git
ssh:git@github.com:Kanject-Lang/springboot-shiro-.git
再附上尚硅谷shiro视频:
链接:https://pan.baidu.com/s/1ltIcvmv5wdyrAbmaV6XX2w
提取码:901y
视频总时长:约3小时