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>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章