美文网首页
shiro加入Ehcache缓存 热部署启动 CacheMana

shiro加入Ehcache缓存 热部署启动 CacheMana

作者: Morgan7 | 来源:发表于2018-06-28 10:15 被阅读0次
    /**
         * 注入Ehcache缓存.
         */
        @Bean
        public EhCacheManager ehCacheManager(){
    
            EhCacheManager ehCacheManager = new EhCacheManager();
    
            ehCacheManager.setCacheManager(ehCacheManagerFactoryBean());
    
            return ehCacheManager;
        }
    
        /**
         * 管理缓存 解决热部署 Ehcache重复创建CacheManager问题
         * @return
         */
        @Bean(name = "ehcacheManager")
        public CacheManager ehCacheManagerFactoryBean() {
            CacheManager cacheManager = CacheManager.getCacheManager("es");
            if(cacheManager == null){
                try {
                    cacheManager = CacheManager.create(ResourceUtils.getInputStreamForPath("classpath:config/ehcache-shiro.xml"));
                } catch (IOException e) {
                    throw new RuntimeException("initialize cacheManager failed");
                }
            }
            return cacheManager;
        }
    

    相关文章

      网友评论

          本文标题:shiro加入Ehcache缓存 热部署启动 CacheMana

          本文链接:https://www.haomeiwen.com/subject/djtgyftx.html