概述
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="cacheManager" ref="shiroCacheManager" />
<property name="authenticator" ref="authenticator"></property>
</bean>
<bean id="authenticator" class="org.apache.shiro.authc.pam.ModularRealmAuthenticator">
<property name="realms">
<list>
<ref bean="authenticationRealm"/>
<ref bean="secondRealm"/>
</list>
</property>
<bean class="org.apache.shiro.authc.pam.FirstSuccessfulStrategy"></bean>
</property>
</bean>
以上配置会出现Configuration error: No realms have been configured! One or more realms must be present to execute an authorization operation.
改成以下配置就可以了,authenticator和realms的先后顺序导致的问题
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="cacheManager" ref="shiroCacheManager" />
<property name="authenticator" ref="authenticator"></property>
<property name="realms">
<list>
<ref bean="authenticationRealm"/>
<ref bean="secondRealm"/>
</list>
</property>
</bean>
<bean id="authenticator" class="org.apache.shiro.authc.pam.ModularRealmAuthenticator">
<property name="authenticationStrategy">
<bean class="org.apache.shiro.authc.pam.FirstSuccessfulStrategy"></bean>
</property>
</bean>
最后
以上就是文静雪碧为你收集整理的shiro 多realms集成:Configuration error: No realms have been configured! One or more realms must be pr的全部内容,希望文章能够帮你解决shiro 多realms集成:Configuration error: No realms have been configured! One or more realms must be pr所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复