【问题标题】:CacheManager properties have been set- Apache ShiroCacheManager 属性已设置 - Apache Shiro
【发布时间】:2012-02-04 00:04:48
【问题描述】:

如何在使用 Apache shiro 时设置 cacheManager 属性。在调试时,我得到了类似的信息,

80104 [1045903843@qtp-967078155-3] INFO org.apache.shiro.realm.AuthorizingRealm - No cache or cacheManager properties have been set.  Authorization cache cannot be obtained.

我正在使用 JSF2 和 Google Cloud SQL。

【问题讨论】:

    标签: google-app-engine shiro


    【解决方案1】:

    如果使用 Shiro 的 INI 配置,您可以像设置任何其他 bean 属性一样设置 SecurityManager 的 cacheManager 属性。例如:

    [main]
    
    cacheManager = com.something.impl.SomeCacheManager
    # config cacheManager as necessary, e.g.
    # cacheManager.foo = bar
    
    securityManager.cacheManager = $cacheManager
    

    您可以使用开箱即用的 EhCacheManager 或自己实现 CacheManagerCache 接口以使用自定义缓存后备存储(例如 Memcache、Coherence、GigaSpaces、任何现代 NoSQL 键/值存储,等等……)

    【讨论】:

      【解决方案2】:

      似乎 EhCacheManager 不是 shiro-core 1.2.1 的一部分(无论如何在 Maven 包中)。我通过将以下内容添加到 shiro.ini 中的 [main] 部分解决了这个问题:

      [main]
      builtInCacheManager = org.apache.shiro.cache.MemoryConstrainedCacheManager
      securityManager.cacheManager = $builtInCacheManager
      

      【讨论】:

      • 嗨,Allan - 我们不能强制所有 Shiro 用户依赖 Ehcache,因此 Ehcache 支持以plugin 的形式提供。只需将它添加到您的运行时类路径中,您就可以立即使用 EhCacheManager。 HTH!
      • 啊,不知道。我虽然当你提到它是开箱即用的,它包含在核心库中。谢谢!
      猜你喜欢
      • 2018-09-03
      • 1970-01-01
      • 2020-05-13
      • 2013-07-27
      • 1970-01-01
      • 1970-01-01
      • 2012-06-23
      • 2013-03-20
      相关资源
      最近更新 更多