shiro 的配置文件

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:tx="http://www.springframework.org/schema/tx"
 xmlns:context="http://www.springframework.org/schema/context"
 xmlns:aop="http://www.springframework.org/schema/aop"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
 http://www.springframework.org/schema/tx
 http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
 http://www.springframework.org/schema/context
 http://www.springframework.org/schema/context/spring-context-3.0.xsd
 http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"
 default-lazy-init="false">

 <!-- 項目自定义的Realm -->
 <bean id="shiroDbRealm" class="com.szm.core.dao.realm.ShiroDbRealm"></bean>

 <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
  <property name="realm" ref="shiroDbRealm" />
  <property name="sessionManager" ref="sessionManager" />
  <property name="sessionMode" value="http"></property>
 </bean>

 <!-- Shiro Filter -->
 <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="/homepage.jsp" />
  <property name="unauthorizedUrl" value="/WEB-INF/jsp/errorPage/unauthorized.jsp" />
  <property name="filterChainDefinitions">
   <value>
    /login.jsp* = anon
    /test/login.action* = anon
    /index.jsp*= anon
    /error.jsp*= anon
    /*.jsp* = authc
    /*.action* = authc
   </value>
  </property>
 </bean>

 <bean id="sessionDAO"
  class="org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO" />

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

 <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />

 <bean
  class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"
  depends-on="lifecycleBeanPostProcessor" >
        <property name="proxyTargetClass" value="true"></property>
    </bean>
     
 <bean
  class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
  <property name="securityManager" ref="securityManager" />
 </bean>
</beans>

 

如果出现代理异常:问题肯定在:spring配置文件默认的jdk动态代理,而cglib目标对象动态代理则必须配置   <property name="proxyTargetClass" value="true"></property>。代理冲突,则都改为cglib代理

如果是注解报异常:在action中的service实体类用spring注解@Autowired,而且要放在它的set方法上面。切记,创建的service实体类的名称一定要和service的接口实现类名一样。

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值