标签:manager mic image max art targe etc bsp pool
在添加权限控制后,添加方法 查看
当用户访问”获取用户信息”、”新增用户”和”删除用户”的时,后台输出打印如下信息 ,
Druid数据源SQL监控
为了避免频繁访问数据库获取权限信息,在Shiro中加入缓存
缓存有基于Redis和Ehcache的,本文只介绍基于Redis的
1.Shiro集成Redis的引入依赖
<dependency> <groupId>org.crazycake</groupId> <artifactId>shiro-redis</artifactId> </dependency>
2.Redis配置
spring.redis.host=localhost
spring.redis.port=6379
spring.redis.jedis.pool.max-active=8
spring.redis.jedis.pool.max-wait=-1
spring.redis.jedis.pool.max-idle=8
spring.redis.jedis.pool.min-idle=0
spring.redis.timeout=0
3.在ShiroConfig中配置Redis
public RedisManager redisManager() { RedisManager redisManager = new RedisManager(); return redisManager; } public RedisCacheManager cacheManager() { RedisCacheManager redisCacheManager = new RedisCacheManager(); redisCacheManager.setRedisManager(redisManager()); return redisCacheManager; }
在SecurityManager中加入RedisCacheManager
@Bean public SecurityManager securityManager() { DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); …… securityManager.setCacheManager(cacheManager()); return securityManager; }
4.测试
启动项目
访问访问”获取用户信息”、”新增用户”和”删除用户”,后台只打印一次获取权限信息
Druid数据源SQL监控
Spring boot后台搭建二为Shiro权限控制添加Redis缓存
标签:manager mic image max art targe etc bsp pool
原文地址:https://www.cnblogs.com/baby123/p/11113187.html