cvc-elt.1: Cannot find the declaration of element 'Bohnen'
Ich versuche, ein bean-Objekt, um den Benutzer zu authentifizieren login-Funktionalität mit Spring Security:
ApplicationContext context = new ClassPathXmlApplicationContext(
"com/humandevice/drive/fx/util/applicationContext.xml");
authenticationManager = (AuthenticationManager) context
.getBean("authenticationManager");
Meine applicationContext.xml
unter:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" 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.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"
xmlns:context="http://www.springframework.org/schema/context">
<context:component-scan base-package="com.humandevice.drive.fx">
<context:include-filter type="regex"
expression="com.humandevice.drive.fx.*" />
</context:component-scan>
<bean id="LoginController" alias="loginController" class="controller.LoginController">
<property name="authenticationManager" ref="authenticationManager" />
<property name="applicationContext" ref="applicationContext" />
</bean>
<bean id="applicationContext" alias="applicationContext"
class="org.springframework.context.ApplicationContext;">
</bean>
<authentication-manager alias="authenticationManager">
<authentication-provider user-service-ref="userService">
<password-encoder ref="bCryptPasswordEncoder" />
</authentication-provider>
</authentication-manager>
</beans>
aber ich bekomme diese exception:
Caused by: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 64; cvc-elt.1: Cannot find the declaration of element 'beans'.
Ich habe Schwierigkeiten beim Verständnis der Frage.
Update
Habe ich einige änderungen vorgenommen, um meine XML als solche:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd">
<import resource="/context-service.xml" />
<import resource="/context-repository.xml" />
<context:component-scan base-package="com.humandevice.drive.fx"></context:component-scan>
<authentication-manager>
<authentication-provider user-service-ref="com.humandevice.drive.service.user.IUserService">
<password-encoder ref="bCryptPasswordEncoder" />
</authentication-provider>
</authentication-manager>
</beans:beans>
Ich jetzt bekomme diese exception:
lineNumber: 11; columnNumber: 44; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'import'.
InformationsquelleAutor Asalas77 | 2014-12-11
Du musst angemeldet sein, um einen Kommentar abzugeben.
Ihre Standard-namespace ist
http://www.springframework.org/schema/security
und Sie konfiguriertxmlns:beans="http://www.springframework.org/schema/beans"
dies bedeutet, dass Sie müssen hinzufügen das Präfixbeans:
zu allen tag-formhttp://www.springframework.org/schema/beans
so Ihre XML-sollte wie folgt sein.alias
- tags, weil es war was zu Fehlern führt, aber jetzt bekomme ich dieseConfiguration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security]
Sind Sie mit
spring-security-config
Glas in Ihrer Klasse Weg?Ich erinnere mich, hinzufügen zu pom.xml aber es war nicht da, also habe ich ihn Hinzugefügt. Jetzt habe ich einige changesand aktualisiert die Frage. Bitte werfen Sie einen Blick.
Wieder! verwenden
<beans:import>
statt<import>
InformationsquelleAutor Karthikeyan Vaithilingam
Dieser code wird Ihnen helfen.
InformationsquelleAutor Enli
Für mich, ich habe einfach Ausschneiden und einfügen und speichern von XML-Dateien in der gleichen Stelle und es funktionierte für mich !!
InformationsquelleAutor Chinmoy
Sich für mich irgendwie die änderungen an der applicationContext.xml nicht aktualisiert wurden in den classpath. Also habe ich manuell gelöscht applicationContext.xml die Datei aus dem Klassenpfad und re-build der Anwendung, die mein problem gelöst
InformationsquelleAutor Pancham Goyal
Ich bin völlig unsicher, warum diese seltsame Art von Verhalten. Auch ich Stand vor der gleichen Ausnahme und folgte dem, was
Karthikeyan Vaithilingam
beraten hat. Aber noch ist das Problem nicht behoben. Also ich habe die änderungen rückgängig gemacht, was ich immer getan habe und die Datei gespeichert. Viola!! Ausnahme verschwunden, keine Fehler jetzt.InformationsquelleAutor mannedear