Shiro 配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-3.2.xsd  
    http://www.springframework.org/schema/util
    http://www.springframework.org/schema/util/spring-util-3.2.xsd" default-autowire="byName" default-lazy-init="true">
 <description>Shiro 配置</description>

 <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
  <property name="securityManager" ref="securityManager" />
  <property name="loginUrl" value="/login" />
  <property name="successUrl" value="/index" />
  <property name="unauthorizedUrl" value="/error/noperms.jsp" />
  <property name="filterChainDefinitions">
   <value>
    /error/** = anon
    /resource/** = anon
    /attached/** = anon
    /login* = anon
    /validateCode* = anon
    /tmp_upload/** = anon
    /index.jsp* = anon
    /tchtml/** = anon
    /dfhtml/** = anon
    /fzhtml/** = anon
    /tc/** = anon
    /df/** = anon
    /fz/** = anon
    /activity/** = anon
    /as/** = anon
    /ashtml/** = anon
    /zs/** = anon
    /zshtml/** = anon
    /lt/** = anon
    /lthtml/** = anon

    /WEB-INF/** = authc
    /*.jsp* = authc
    /** = authc
   </value>
  </property>
 </bean>

 <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
  <!--设置自定义realm -->
  <property name="realm" ref="monitorRealm" />
  <property name="cacheManager" ref="cacheManager" />
 </bean>

 <!-- securityManager -->
 <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
  <property name="staticMethod" value="org.apache.shiro.SecurityUtils.setSecurityManager" />
  <property name="arguments" ref="securityManager" />
 </bean>

 <!--自定义Realm 继承自AuthorizingRealm -->
 <bean id="monitorRealm" class="org.cxm.wolf.interceptor.MonitorRealm" />

 <!-- 用户授权信息Cache -->
 <bean id="cacheManager" class="org.apache.shiro.cache.MemoryConstrainedCacheManager" />

</beans>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在使用Shiro配置Redis时,可以按照以下步骤进行操作: 1. 首先,将shiro-redis-tutorial克隆到本地磁盘上,使用以下命令来克隆项目:git clone https://github.com/alexxiyang/shiro-redis-tutorial.git 2. 打开克隆下来的项目,并进入src/main/resources目录下。 3. 在resources目录下,可以找到shiro.ini配置文件。这个文件用于配置ShiroShiro-Redis。可以根据自己的需要对文件进行修改。 4. 如果需要详细了解ShiroShiro-Redis的配置,可以参考Shiro官网或者这个博客:https://blog.csdn.net/LHacker/article/details/10438387 5. 根据项目的需求,可以使用开源项目中的类来实现Redis作为缓存,缓存用户的权限和session信息。同时,还可以使用开源项目中的其他功能,如并发登录限制和密码错误次数限制。 6. 在整合过程中,首先需要进行Redis的配置。可以根据项目的具体情况,对Redis进行相关的优化。 总结:要配置Shiro使用Redis作为缓存,可以参考shiro.ini配置文件,并根据需要进行修改。在整合过程中,可以使用开源项目中的类来实现Redis的相关功能,并根据项目的需求进行优化。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [shiro-redis-tutorial:shiro-redis教程](https://download.csdn.net/download/weixin_42117032/18665099)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [Shiro配置以及redis配置](https://blog.csdn.net/wucaifang819787/article/details/82050394)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [Shiro使用Redis作为缓存(解决Shiro频繁访问Redis)(十一)](https://blog.csdn.net/qq_45822970/article/details/109582568)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值