The corresponding template is strict, but declarations for the context of the element: scan component not found,

I am using Spring 3.2.3.RELEASE with maven to pull the dependencies. When creating a project in Eclipse, the following error appears:

Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 17 in XML document from class path resource [META-INF/spring/application-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 17; columnNumber: 64; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'. 

My appication-context.xml has the following:

 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context/ http://www.springframework.org/schema/context/spring-context-3.2.xsd"> <context:component-scan base-package="com.example" /> 

I know that I am pulling the correct jar files, as my Maven Dependencies show:

Eclipse maven dependencies

Inside META-INF / sping.schemas, I see that I have the correct schema declaration in my bank:

 http\://www.springframework.org/schema/context/spring-context-2.5.xsd=org/springframework/context/config/spring-context-2.5.xsd http\://www.springframework.org/schema/context/spring-context-3.0.xsd=org/springframework/context/config/spring-context-3.0.xsd http\://www.springframework.org/schema/context/spring-context-3.1.xsd=org/springframework/context/config/spring-context-3.1.xsd http\://www.springframework.org/schema/context/spring-context-3.2.xsd=org/springframework/context/config/spring-context-3.2.xsd http\://www.springframework.org/schema/context/spring-context.xsd=org/springframework/context/config/spring-context-3.2.xsd 

I also looked at them to no avail:

Unable to load Spring 3 schemas

The corresponding template is strict, but no declaration was found for the element "tx: annotation-driven"

No ads found for item context: scan component

The corresponding template is strict, but declarations for the context of the element: scan component not found.

Please help, this is driving me crazy .... :(

+6
source share
1 answer

First you need to fix your dependencies. You mix Spring 3.2.3 and 2.0.6 jars (these are problems waiting for them to happen).

Next to the fact that your ad is incorrect http://www.springframework.org/schema/context/ should be http://www.springframework.org/schema/context .

+14
source

Source: https://habr.com/ru/post/955403/


All Articles