Prefix “context” for element “context:component-scan” or “context:annotation-config” is not bound : Spring error

When you are working on spring or spring mvc application, you may encounter below error message.
org.xml.sax.SAXParseException: The prefix “context” for element “context:component-scan” is not bound .
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.

Here you might get above exception because you are missing context namespace xmlns:context here.
When you add below line in above xml.

so your final xml file will look as below:

I hope it will solve context is not bound error.

Add Comment