복붙노트

[SPRING] 요소 "context : component-scan"에 대한 접두어 "context"는 바인딩되지 않습니다.

SPRING

요소 "context : component-scan"에 대한 접두어 "context"는 바인딩되지 않습니다.

나는 봄 mvc에서 일하고 있는데이 오류가 떠올랐다.

org.xml.sax.SAXParseException : "context : component-scan"요소에 대한 접두사 "context"가 바인딩되지 않습니다.

여기는 디스패처 서블릿입니다.

<?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: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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

    <mvc:annotation-driven />

    <context:component-scan base-package="com.web" /> 

해결법

  1. ==============================

    1.xmlns : context 선언이 누락되었지만 선언 한 경우 이러한 유형의 오류가 발생합니다. 잘못된 코딩에 대해서는 "com.web"패키지의 클래스를 확인하십시오.

    xmlns : context 선언이 누락되었지만 선언 한 경우 이러한 유형의 오류가 발생합니다. 잘못된 코딩에 대해서는 "com.web"패키지의 클래스를 확인하십시오.

  2. ==============================

    2.가끔 네임 스페이스를 추가하는 것을 잊어 버리는 문제가 있습니다. 구성 파일 만들기 마법사 또는 이름 공간 탭에서이 작업을 수행해야합니다. 적절한 네임 스페이스를 선택하십시오 (이 경우 컨텍스트 여야 함).

    가끔 네임 스페이스를 추가하는 것을 잊어 버리는 문제가 있습니다. 구성 파일 만들기 마법사 또는 이름 공간 탭에서이 작업을 수행해야합니다. 적절한 네임 스페이스를 선택하십시오 (이 경우 컨텍스트 여야 함).

  3. ==============================

    3.dispatcher-servlet.xml 파일 자체의 bean에 다음을 추가합니다.

    dispatcher-servlet.xml 파일 자체의 bean에 다음을 추가합니다.

    그래서 파일은 다음과 같습니다.

    <?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>
    
  4. ==============================

    4.spring-configuration.xml 파일을 만들 때 다음 단계를 수행 할 수 있습니다. 이름을 입력 한 후 "다음"을 클릭하면 많은 확인란을 사용할 수 있습니다. 'bean', 'mvc', 'context', 'p' 아래층을 선택하지 않아도 일부 체크 박스가 표시됩니다. 이클립스 / 스프링 지원 인 기본 설정을 선택하기 때문입니다.

    spring-configuration.xml 파일을 만들 때 다음 단계를 수행 할 수 있습니다. 이름을 입력 한 후 "다음"을 클릭하면 많은 확인란을 사용할 수 있습니다. 'bean', 'mvc', 'context', 'p' 아래층을 선택하지 않아도 일부 체크 박스가 표시됩니다. 이클립스 / 스프링 지원 인 기본 설정을 선택하기 때문입니다.

    감사,

  5. from https://stackoverflow.com/questions/7131479/the-prefix-context-for-element-contextcomponent-scan-is-not-bound by cc-by-sa and MIT license