Java 在基于Spring的应用程序中启用Shiro注释
我有两个模块的项目-网络和商业 在web模块中,有一个带有配置的shiro.ini文件(如教程中所示–带有我自己的属性) 在业务模块中,有一个applicationContext.xml文件,其代码如下:Java 在基于Spring的应用程序中启用Shiro注释,java,spring,shiro,Java,Spring,Shiro,我有两个模块的项目-网络和商业 在web模块中,有一个带有配置的shiro.ini文件(如教程中所示–带有我自己的属性) 在业务模块中,有一个applicationContext.xml文件,其代码如下: <bean id="iniRealm" class="org.apache.shiro.realm.text.IniRealm"> <property name="resourcePath" value="file:C:\project\webmodule\src\m
<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>
但是如果我想使用注释,比如@requireauthentication
,它就不起作用
applicationContext.xml中的配置是否足够?哪里会出错?web模块中的身份验证工作正常
过滤器有问题吗?我是否必须定义两个过滤器,一个是org.springframework.web.filter.DelegatingFilterProxy
,另一个是org.apache.shiro.web.servlet.ShiroFilter
?
谢谢您的建议。您的配置已经足够了。如果您有其他AOP设置,如
BeanNameAutoProxyCreator
,则还需要将beanAuthorizationAttributeSourceVisor
添加到属性interceptorNames
中