Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

context:component-scan" is not bound

Tags:

java

spring

Am new to spring and I know this question has been asked many times, but I had to ask it again.

I guess,I have done appropriate namespace declarations, but still facing the error "The prefix "context" for element "context:component-scan" is not bound." There is a similar question here, but I dint get the answer

Here is my xml document, Is it that my namespace is not correct ?

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="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-3.0.xsd     http://www.springframework.org/schema/context/spring-context-3.0.xsd">        <bean id="point1" class="org.sri.proj.Point">         <property name="x" value="0" />         <property name="y" value="0" />     </bean>      <bean id="point2" class="org.sri.proj.Point">         <property name="x" value="10" />         <property name="y" value="10" />     </bean>      <context:component-scan base-package="org.sri.proj"/>  </beans> 
like image 873
Srivatsa N Avatar asked May 21 '13 15:05

Srivatsa N


1 Answers

Add the context namespace declaration to the beans tag definition in the application context file

<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.0.xsd     http://www.springframework.org/schema/context     http://www.springframework.org/schema/context/spring-context-3.0.xsd">   
like image 101
Reimeus Avatar answered Oct 05 '22 14:10

Reimeus