我是靠谱客的博主 文静雪碧,这篇文章主要介绍shiro 多realms集成:Configuration error: No realms have been configured! One or more realms must be pr,现在分享给大家,希望可以做个参考。

<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>

        <property name="authenticationStrategy">
            <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内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(138)

评论列表共有 0 条评论

立即
投稿
返回
顶部