SpringMVC集成Shiro并采用多Realm认证时,出现: Configuration error: No realms have been configured! One or more realms must be present to execute an authorization operation.
出错时的XML配置如下:主留意绿色与橙色部分的顺序
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="realms"> <list> <ref bean="systemRealm"/> <ref bean="openldapRealm"/> </list> </property><property name="authenticator" ref="authenticator" />
<property name="sessionManager" ref="sessionManager" /> <property name="cacheManager" ref="shiroCacheManager" /> </bean>以上配置就会出现错误,说找不到Realm。一时想不明白为什么会有这个提示,我不是配置好了么?
突然想试下会不会是参数的顺序导致的?
改为:
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="authenticator" ref="authenticator" /><property name="realms">
<list> <ref bean="systemRealm"/> <ref bean="openldapRealm"/> </list> </property> <property name="sessionManager" ref="sessionManager" /> <property name="cacheManager" ref="shiroCacheManager" /> </bean>立马就好了。Why?看来平时又忽略了重要的知识点