cuiyi's blog(崔毅 crazycy)

          記錄點(diǎn)滴 鑒往事之得失 以資于發(fā)展
          數(shù)據(jù)加載中……

          SpringMVC+MyBatis - 8 Shiro異常:EhCache initialization exception: Another unnamed CacheManager already exists in the same VM

          異常1: EhCache initialization exception: Another unnamed CacheManager already exists in the same VM
          具體錯(cuò)誤如下:
          Another CacheManager with same name 'cacheManager' already exists in the same VM. Please > provide unique names for each CacheManager in the config or do one of following: 
          1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary 
          2. Shutdown the earlier cacheManager before creating new one with same name. The source of the existing CacheManager is: DefaultConfigurationSource [ ehcache.xml or ehcache-failsafe.xml ]

          一般材料是這樣說(shuō)的:
          <bean id="ehCacheManager" 
              class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
              p:configLocation="classpath:org/tradinglink/cache/echcache-shiro.xml"
              p:shared="true"/>

          但是經(jīng)過(guò)實(shí)踐是要這樣做的:
          <bean id="shiroEncacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
          <property name="cacheManager" ref="ehCacheManager"/>
          </bean>
          <bean id="ehCacheManager" 
              class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
              p:configLocation="classpath:org/tradinglink/cache/echcache-shiro.xml"
              p:shared="true"/>

          一段關(guān)于完整的配置如下
          <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
          <property name="securityManager" ref="securityManager" />
          <property name="loginUrl" value="/login.jsp" />
          <property name="successUrl" value="/index.jsp" />
          <property name="unauthorizedUrl" value="/unauthorized.jsp" />
          <property name="filters">
          <map>
          <entry key="authc" value-ref="formAuthenticationFilter"></entry>
          </map>
          </property>
          <!-- will config in db, and then read into filterChainDefinitionsMap property -->
          <property name="filterChainDefinitions">
          <value>
          /login = authc
          /logout = logout
          /resource/** = anon
          /images/**= anon
          /css/**= anon
          /javascript/**= anon
          <!-- /welcome = perms[accout:edit] -->
          <!-- /security/account/view.do=authc,perms[SECURITY_ACCOUNT_VIEW] -->
          /** = anon
          </value>
          </property>
          </bean>

          <!--一段關(guān)于securityManager的完整的配置如下-->
          <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
              <property name="realm" ref="myRealm"/>
              <property name="sessionMode" value="native"/>
              <property name="sessionManager" ref="sessionManager"/>
              <property name="cacheManager" ref="cacheManager"/>
          </bean>

          <bean id="cacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
              <property name="cacheManager" ref="ehCacheManager"/>
          </bean>

          <bean id="ehCacheManager" 
              class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/>

          <bean id="sessionManager"
              class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
              <property name="sessionDAO" ref="sessionDAO"/>
          </bean>

          <bean id="sessionDAO" 
              class="org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO">
              <property name="activeSessionsCacheName" value="shiro-activeSessionCache" />
          </bean>
          <bean id="myRealm" class="com.foo.MyRealm"/>

          posted on 2014-07-13 00:07 crazycy 閱讀(5346) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): JavaEE技術(shù)

          主站蜘蛛池模板: 福泉市| 刚察县| 大港区| 湟中县| 库尔勒市| 宜兰县| 大新县| 昔阳县| 云浮市| 凤山市| 时尚| 英超| 舒兰市| 镇原县| 邳州市| 鄂尔多斯市| 万载县| 克东县| 金昌市| 黎城县| 柘城县| 陕西省| 永春县| 洪江市| 扶沟县| 阿拉善左旗| 平泉县| 楚雄市| 嘉定区| 水城县| 密山市| 乐山市| 牡丹江市| 托克逊县| 东乡族自治县| 广昌县| 彭山县| 吴堡县| 竹北市| 镇平县| 三亚市|