zoukankan      html  css  js  c++  java
  • org.apache.shiro.session.UnknownSessionException: There is no session with

    <bean id="sessionDAO"
    class="org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO">
    <property name="cacheManager" ref="shiroCacheManager" />
    </bean>
    <bean id="shiroCacheManager" class="net.cache.redis.RedisCacheManager" />

    想跟换Shiro中缓存系统,试了很多方法,一直报错 org.apache.shiro.session.UnknownSessionException: There is no session with 

    要实现自己的Redis缓存,还是使用自带的EnterpriseCacheSessionDAO,只要把它需要的 cacheManager 换成自己的redis cache 实现就可以了。测试启动后没有再出现 no session 问题了

    import java.util.concurrent.ConcurrentHashMap;
    import java.util.concurrent.ConcurrentMap;
    
    import javax.annotation.Resource;
    
    import org.apache.shiro.cache.Cache;
    import org.apache.shiro.cache.CacheException;
    import org.apache.shiro.cache.CacheManager;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    
    public class RedisCacheManager implements CacheManager{
        
         private static final Logger logger = LoggerFactory.getLogger(RedisCacheManager.class);
    
            // fast lookup by name map
            private final ConcurrentMap<String, Cache> caches = new ConcurrentHashMap<String, Cache>();
    
            @Resource
            private RedisDao redisDao;
    
            public <K, V> Cache<K, V> getCache(String name) throws CacheException {
                logger.debug("获取名称为: " + name + " 的RedisCache实例");
                Cache<K, V> c = caches.get(name);
                if (c == null) {
                    c = new RedisCache<K, V>(redisDao);
                    caches.put(name, c);
                }
                return c;
            }
        
    }
  • 相关阅读:
    react的路由权限控制
    react的路由中的switch和exact的使用
    react中antd的表格自定义展开
    webstorm的git操作使用
    ES6的相关语法
    vue导出文件下载
    vue如何解析xml文件 x2js
    ES6模板字符串
    彻底卸载微软拼音输入法
    systemverilog新增的always_comb,always_ff,和always_latch语句
  • 原文地址:https://www.cnblogs.com/nanahome/p/7788453.html
Copyright © 2011-2022 走看看