2016-10-02 2 views
0

ich Fehler mit Federkonfiguration:Ungültige Inhalt wurde beginnend mit dem Element 'Authentifizierungs-Manager' gefunden

Invalid content was found starting with element 'authentication-manager'. One of '{"http://www.springframework.org/schema/beans":import, "http://www.springframework.org/schema/beans":alias, "http://www.springframework.org/schema/beans":bean, WC[##other:"http://www.springframework.org/schema/beans"]}' is expected. 

Hier ist die Bohne XML-Datei:

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation=" 
    http://www.springframework.org/schema/beans  
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.0.xsd 
    http://www.springframework.org/schema/mvc 
    http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> 

    <context:component-scan base-package="com.rsc."/> 
    <mvc:annotation-driven /> 

    <authentication-manager alias="authenticationManager"> 
     <authentication-provider user-service-ref="userDetailsServiceImpl"> 
      <password-encoder ref="encoder"></password-encoder> 
     </authentication-provider> 
    </authentication-manager> 

    <bean id="userDetailsServiceImpl" class="com.rsc.service.UserDetailsServiceImpl"></bean> 

    <bean id="encoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder"> 
     <constructor-arg name="strength" value="11"/> 
    </bean> 

    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
     <property name="prefix" value="/WEB-INF/views/"/> 
     <property name="suffix" value=".jsp"/> 
    </bean> 
</beans> 

Ich habe alle erforderlichen Bean hinzugefügt Konfiguration, aber immer noch bekomme ich Fehler. Was fehlt mir in der Konfiguration?

Antwort

1

Ich denke, Sie müssen den Namespace Federsicherheit hinzufügen.

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:security="http://www.springframework.org/schema/security"   
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation=" 
     http://www.springframework.org/schema/beans  
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context-3.0.xsd 
     http://www.springframework.org/schema/mvc 
     http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
     http://www.springframework.org/schema/security 
     http://www.springframework.org/schema/security/spring-security-3.1.xsd"> 

    [...] 

    <security:authentication-manager> 
     ... 
    </security:authentication-manager> 

    [...] 

</beans> 

seit beans ist Ihre Standard-Namespace Feder die authentication-manager dort zu finden versucht. Daher müssen Sie den Namespace security einführen. Weitere Informationen finden Sie in der Dokumentation: http://docs.spring.io/spring-security/site/docs/3.1.x/reference/springsecurity-single.html#d0e507

+0

Ich habe es schon herausgefunden aber danke für die richtige Antwort – Satyadev

+0

Great @Satyadev. Bitte! –

Verwandte Themen