The prefix “context” for element “context:component-scan” is not bound

后端 未结 5 812
醉话见心
醉话见心 2020-12-30 03:14

I am working on spring3 mvc and came up with this error

org.xml.sax.SAXParseException: The prefix \"context\" for element \"context:component-scan\" is not bound.

相关标签:
5条回答
  • 2020-12-30 03:46

    Such type of error comes when You're missing the xmlns:context declaration but you have declared it. Check your classes in "com.web" package for any wrong coding.

    0 讨论(0)
  • 2020-12-30 03:47

    When you're create spring-configuration.xml file you can follow these steps.After enter the name click "Next" now so many check boxes available the you can select 'bean','mvc','context','p'.no need to select downstairs shows some check boxes.because it will select default settings which is your eclipse/spring support.

    Thanks,

    0 讨论(0)
  • 2020-12-30 04:00

    Sometime the problem is in forgetting to add namespace. you should do that in the wizard of creating the config file or in the name space tab after it been created. select the proper namespaces, in this case should be context, and save.

    0 讨论(0)
  • 2020-12-30 04:03

    Add the following in the beans of dispatcher-servlet.xml file itself :

    so your file looks like :

    <?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
     http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd
     http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
    
    <context:component-scan base-package="com.Project_name.Controller"></context:component-scan>
    </beans>
    
    0 讨论(0)
  • 2020-12-30 04:04

    You may lost this profile which is : xmlns:context="http://www.springframework.org/schema/context". Please write it.

    0 讨论(0)
提交回复
热议问题