- 项目启动后输入:http://localhost/
- 该项目中, 增加了对url的拦截URLPermissionsFilter,
- 用admin/123456,拥有index权限reports未任何权限, lance/123456尚未分配任何权限.
- 参考schema.sql
- shiro Cache交于Redis进行管理
- springmvc-shiro采用xml配置, 参考demo-springmvc-shiro
Add dependencies to pom
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>
Shiro-Redis configuration
@Bean(name="shrioRedisCacheManager")
@DependsOn(value="redisTemplate")
public ShrioRedisCacheManager redisCacheManager() {
ShrioRedisCacheManager cacheManager = new ShrioRedisCacheManager(redisTemplate());
return cacheManager;
}
@Bean(name="redisTemplate")
public RedisTemplate<byte[], Object> redisTemplate() {
RedisTemplate<byte[], Object> template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory());
return template;
}
@Bean
public JedisConnectionFactory connectionFactory(){
JedisConnectionFactory conn = new JedisConnectionFactory();
conn.setDatabase(3);
conn.setHostName("127.0.0.1");
conn.setPassword("123456");
conn.setPort(6379);
conn.setTimeout(3000);
return conn;
}
//CacheManager
public class ShrioRedisCacheManager extends AbstractCacheManager{
private RedisTemplate<byte[], Object> redisTemplate;
public ShrioRedisCacheManager(RedisTemplate<byte[], Object> redisTemplate) {
this.redisTemplate = redisTemplate;
}
@Override
protected Cache<byte[], Object> createCache(String name) throws CacheException {
return new ShrioRedisCache<byte[], Object>(redisTemplate, name);
}
}