cvc-elt.1: Impossible de trouver la déclaration de l'élément 'beans'
Je suis en train d'essayer d'obtenir un haricot objet à authentifier l'utilisateur la fonctionnalité de login avec Ressort de Sécurité:
ApplicationContext context = new ClassPathXmlApplicationContext(
"com/humandevice/drive/fx/util/applicationContext.xml");
authenticationManager = (AuthenticationManager) context
.getBean("authenticationManager");
Mon applicationContext.xml
est ci-dessous:
<?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>
mais je bénéficier de cette exception:
Caused by: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 64; cvc-elt.1: Cannot find the declaration of element 'beans'.
J'ai de la difficulté à comprendre le problème.
Mise à jour
J'ai apporté quelques modifications à mon XML en tant que tel:
<?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>
Je reçois cette 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'.
source d'informationauteur Asalas77
Vous devez vous connecter pour publier un commentaire.
Votre espace de noms par défaut est
http://www.springframework.org/schema/security
et vous avez configuréxmlns:beans="http://www.springframework.org/schema/beans"
cela signifie que vous devez ajouter le préfixebeans:
à tous les balise de formulairehttp://www.springframework.org/schema/beans
de sorte que votre XML doit être comme suit.Ce code va vous aider.
Pour moi, je viens de le couper et coller et enregistrer des fichiers XML dans le même endroit et il a travaillé pour moi !!
Pour moi en quelque sorte les modifications apportées à la applicationContext.xml n'ont pas été mis à jour dans le classpath. J'ai donc supprimé manuellement le applicationContext.xml fichier de chemin de classe et de re-construction de la demande qui a résolu mon problème