# spring-boot-shiro, 依赖spring-boot-parent
* [spring-boot](http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/)
* [mybatis](https://github.com/mybatis/spring-boot-starter)
* [druid](https://github.com/alibaba/druid)
* [shiro](http://shiro.apache.org/)
* [redis](http://redis.io/)
* [jedis](https://github.com/xetorthio/jedis)
> * 项目启动后输入:http://localhost/
> * 该项目中, 增加了对url的拦截[URLPermissionsFilter](https://github.com/leelance/spring-boot-all/blob/master/spring-boot-shiro/src/main/java/com/lance/shiro/config/URLPermissionsFilter.java),
> * 用admin/123456,拥有index权限reports未任何权限, lance/123456尚未分配任何权限.
> * 参考[schema.sql](https://github.com/leelance/spring-boot-all/blob/master/spring-boot-shiro/src/main/resources/init-sql/schema.sql)
> * shiro Cache交于Redis进行管理
> * springmvc-shiro采用xml配置, 参考[demo-springmvc-shiro](https://github.com/leelance/demo/tree/master/demo-springmvc-shiro)
Add dependencies to pom
```xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>
```
Shiro-Redis configuration
```java
@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);
}
}
```
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
springboot shiro redis缓存和session共享例子 (228个子文件)
ShiroConfig.class 6KB
ShiroConfig.class 6KB
ShrioRedisCache.class 6KB
ShrioRedisCache.class 6KB
UserRealm.class 3KB
UserRealm.class 3KB
SerializeUtils.class 3KB
SerializeUtils.class 3KB
URLPermissionsFilter.class 3KB
UserServiceImpl.class 3KB
UserServiceImpl.class 3KB
URLPermissionsFilter.class 3KB
LoginController.class 2KB
LoginController.class 2KB
DruidConfig.class 2KB
DruidConfig.class 2KB
ModuleInfo.class 2KB
ModuleInfo.class 2KB
UserInfo.class 1KB
UserInfo.class 1KB
UserMapperTest.class 1KB
ShrioRedisCacheManager.class 1KB
ShrioRedisCacheManager.class 1KB
ModuleServiceImpl.class 859B
ModuleServiceImpl.class 859B
SimpleApplication.class 857B
SimpleApplication.class 857B
IndexController.class 815B
IndexController.class 815B
RedisConfig.class 543B
RedisConfig.class 543B
UserMapper.class 542B
UserMapper.class 542B
ModuleMapper.class 534B
ModuleMapper.class 534B
UserService.class 483B
UserService.class 483B
ModuleService.class 261B
ModuleService.class 261B
.classpath 1KB
org.eclipse.wst.common.component 794B
org.eclipse.wst.jsdt.ui.superType.container 49B
bootstrap.min.css 120KB
bootstrap.min.css 120KB
bootstrap.min.css 120KB
bootstrap-theme.min.css 23KB
bootstrap-theme.min.css 23KB
bootstrap-theme.min.css 23KB
layer.css 14KB
layer.css 14KB
layer.css 14KB
dashboard.css 2KB
dashboard.css 2KB
dashboard.css 2KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.eot 20KB
loading-0.gif 6KB
loading-0.gif 6KB
loading-0.gif 6KB
loading-2.gif 2KB
loading-2.gif 2KB
loading-2.gif 2KB
loading-1.gif 701B
loading-1.gif 701B
loading-1.gif 701B
.gitignore 40B
guava-19.0.jar 2.2MB
druid-1.0.20.jar 2.03MB
mybatis-3.4.0.jar 1.52MB
ojdbc14-10.2.0.4.0.jar 1.48MB
jackson-databind-2.8.5.jar 1.18MB
ehcache-core-2.5.0.jar 1.15MB
log4j-core-2.6.2.jar 1.14MB
spring-context-4.3.5.RELEASE.jar 1.08MB
spring-data-redis-1.7.6.RELEASE.jar 1.07MB
spring-core-4.3.5.RELEASE.jar 1.06MB
spring-boot-autoconfigure-1.4.3.RELEASE.jar 950KB
spring-webmvc-4.3.5.RELEASE.jar 893KB
spring-web-4.3.5.RELEASE.jar 797KB
spring-beans-4.3.5.RELEASE.jar 744KB
hibernate-validator-5.2.4.Final.jar 688KB
spring-data-commons-1.12.6.RELEASE.jar 679KB
spring-boot-1.4.3.RELEASE.jar 645KB
commons-collections-3.2.2.jar 575KB
jedis-2.8.2.jar 528KB
spring-jdbc-4.3.5.RELEASE.jar 417KB
jstl-1.2.jar 405KB
fastjson-1.2.12.jar 380KB
commons-lang3-3.2.1.jar 376KB
spring-aop-4.3.5.RELEASE.jar 371KB
shiro-core-1.2.5.jar 371KB
jackson-core-2.8.5.jar 274KB
snakeyaml-1.17.jar 267KB
spring-tx-4.3.5.RELEASE.jar 261KB
spring-expression-4.3.5.RELEASE.jar 257KB
commons-beanutils-1.9.3.jar 240KB
log4j-api-2.6.2.jar 194KB
spring-context-support-4.3.5.RELEASE.jar 183KB
spring-session-1.2.2.RELEASE.jar 177KB
共 228 条
- 1
- 2
- 3
资源评论
- 草莓味ゞ衬衫2021-01-18工程不完整。
- weixin_389862162019-08-15这个东西,还不错
- lqf8022018-07-29调不了,不好用
- cbynietg2018-07-31垃圾的东西,工程不完整。
foxhuyy
- 粉丝: 0
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功