Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The matching wildcard is strict, but no declaration can be found for element 'context:component-scan

Tags:

java

spring

I am getting the following errors while trying my first spring project:

Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan 

Here is the applicationContext.xml:

<?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:p="http://www.springframework.org/schema/p"        xmlns:aop="http://www.springframework.org/schema/aop"        xmlns:tx="http://www.springframework.org/schema/tx"        xmlns:context="http://www.springframework.org/schema/context"        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">          <context:component-scan base-package="com.xyz" />  </beans> 

What is causing the error?

like image 289
user93796 Avatar asked Nov 27 '12 17:11

user93796


1 Answers

You have not specified the schema location of the context namespace, that is the reason for this specific error:

<beans .....   xmlns:context="http://www.springframework.org/schema/context"   xsi:schemaLocation="     http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-2.5.xsd     http://www.springframework.org/schema/aop     http://www.springframework.org/schema/aop/spring-aop-2.5.xsd     http://www.springframework.org/schema/tx     http://www.springframework.org/schema/tx/spring-tx-2.5.xsd     http://www.springframework.org/schema/context     http://www.springframework.org/schema/context/spring-context.xsd"> 
like image 57
Biju Kunjummen Avatar answered Oct 07 '22 14:10

Biju Kunjummen