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 .
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.



    
    

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

xmlns:context="http://www.springframework.org/schema/context"

so your final xml file will look as below:



    
    

I hope it will solve context is not bound error.

[social_share share_on="facebook,twitter,linkedin,whatsapp"][post_navigator in_same_term="true"]

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.