org.xml.sax.SAXParseException: The prefix “context” for element “context:component-scan” is not bound .
or
org.xml.sax.SAXParseException: The prefix “context” for element “context:annotation-config” is not bound .
This issue generally occurs when you do not include context namespace.
For example: Lets say you have below xml configuration file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc" 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" > <context:annotation-config /> <context:component-scan base-package="controller" /> </beans> |
Here you might get above exception because you are missing context namespace xmlns:context here.
When you add below line in above xml.
1 2 3 |
xmlns:context="http://www.springframework.org/schema/context" |
so your final xml file will look as below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" 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" > <context:annotation-config /> <context:component-scan base-package="controller" /> </beans> |
I hope it will solve context is not bound error.