我有兩個模塊的項目 - web和buisness。在基於Spring的應用程序中啓用Shiro註釋
在網絡模塊,有一個與配置的shiro.ini文件(如教程 - https://github.com/lhazlewood/apache-shiro-tutorial-webapp/blob/step7/src/main/webapp/WEB-INF/shiro.ini - 用我自己的屬性)。
在樓內設有商務模塊,沒有與此代碼applicationContext.xml文件:
<bean id="iniRealm" class="org.apache.shiro.realm.text.IniRealm">
<property name="resourcePath" value="file:C:\project\webmodule\src\main\webapp\WEB-INF\shiro.ini" />
</bean>
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor" />
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="realm" ref="iniRealm" />
</bean>
<bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
<property name="securityManager" ref="securityManager" />
</bean>
但是,如果我想使用的註釋,像@RequiresAuthentication
,這是行不通的。
applicationContext.xml中的配置是否足夠?哪裏可以是一個錯誤?在網絡模塊認證工作正常。
它可能是過濾器的問題?我是否必須定義兩個過濾器,一個是<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
,另一個是<filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
? 謝謝你的任何建議。