直接上代码,
applicationContext.xml 中的配置
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:dbconfig.properties</value>
<value>classpath:redis.properties</value>
</list>
</property>
</bean>
<import resource="spring-redis.xml"/>
<!-- ================ Shiro start ================ -->
<!--shiro-redis redisCacheManager-->
<bean id="redisCacheManager" class="org.crazycake.shiro.RedisCacheManager">
<property name="expire" value="10800"/>
<property name="keyPrefix" value="shiro_redis_session:"/>
<property name="redisManager" ref="redisClient"/>
</bean>
<!-- 項目自定义的Realm -->
<bean id="shiroRealm" class="com.douples.framework.interceptor.shiro.ShiroRealm" >
<property name="cacheManager" ref="redisCacheManager"/>
</bean>
<bean id="redisSessionDAO" class="org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO" />
<!--sessionManager-->
<bean id="sessionManager" class="com.douples.common.util.RedisWebSessionManager">
<property name="sessionDAO" ref="redisSessionDAO"/>
<property name="globalSessionTimeout" value="7200000"/>
<!-- <property name="sessionValidationInterval" value="2000"/> -->
<!-- <property name="sessionValidationSchedulerEnabled" value="true"/> -->
<property name="sessionIdCookie" ref="simpleCookie"/>
<property name="sessionIdCookieEnabled" value="true"/>
</bean>
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManag