# hello-world-spring-boot **Repository Path**: w1365/hello-world-spring-boot ## Basic Information - **Project Name**: hello-world-spring-boot - **Description**: 学习使用SpringBoot 整合其它开源组件 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2024-12-16 - **Last Updated**: 2024-12-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # hello-world-spring-boot - SpringBoot整合H2内存数据库 - mybatis-plus使用入门 - spring cache abstraction使用入门 - 注意添加`@EnableCaching` 开启缓存 - 缓存注解既可以加在接口上,也可以加在实现类中,建议加在接口方法上 - SpringBoot集成JWT实现token验证 - SpringBoot集成Shiro之INI认证篇 - SpringBoot + Shiro 避开各种坑 - SpringBoot + Shiro + JWT 实现token验证 ## 配置 - `mybatis-plus`配置控制台打印完整带参数SQL语句 ```$xslt mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl ``` - 配置`EhCache`做集中式缓存 ```$xslt #使用缓存的类型 spring.cache.type=ehcache #使用缓存的地址 spring.cache.ehcache.config=classpath:config/ehcache-config.xml ``` - 总结一下 springboot 整合 shiro 的流程 ```aidl (1)添加对应依赖 (2)添加shiro验证过程中所需要的bean、方法、持久层信息。 (3)重新自定义的继承自AuthorizingRealm的Realm。 AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken)认证方法流程 从token中取出用户信息。 根据获得的用户信息从数据库中查找user对象。 进行判断,若无此用户,则返回null,有的话则将其交给AuthenticatingRealm使用CredentialsMatcher进行密码匹配,密码匹配的方式可以自定义实现。。 返回authenticatingRealm。 AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection)权限验证方法流程 从principalCollection中获取用户信息。 根据用户信息获取权限信息,将权限信息放入authorizationInfo中(shiro会自动进行权限验证管理)。 返回authorizationInfo。 (4)将shiro配置到项目中。 由于我们对密码进行了加密,所以需要创建凭证匹配器CredentialsMatcher,用来匹配授权认证的时候的密码。 创建realm并将凭证匹配器CredentialsMatcher加入到realm中。 创建SecurityManager并将realm设到其中 创建ShiroFilterFactoryBean,并将SecurityManager注入其中。 创建AuthorizationAttributeSourceAdvisor 开启AOP注解支持 ``` - 打包跳过测试 ```$xslt true ``` ## 参考 - SpringBoot整合H2内存数据库:https://www.cnblogs.com/V1haoge/p/9959855.html - mybatis-plus使用入门 - spring cache abstraction使用入门:https://blog.csdn.net/newbie_907486852/article/details/81475674 - SpringBoot集成JWT实现token验证:https://www.jianshu.com/p/e88d3f8151db - SpringBoot集成Shiro之INI认证篇:https://www.jianshu.com/p/766c8662a8b6 - SpringBoot + Shiro 避开各种坑:https://www.cnblogs.com/HowieYuan/p/9259638.html - SpringBoot + Shiro + JWT 实现token验证:https://www.cnblogs.com/HowieYuan/p/9259650.html