복붙노트

[SPRING] 컨텍스트 : 구성 요소 스캔 "이 바인딩되지 않았습니다.

SPRING

컨텍스트 : 구성 요소 스캔 "이 바인딩되지 않았습니다.

봄에 새롭다. 그리고 나는이 질문이 여러 번 부탁 받았음을 알고 있지만, 나는 다시 물어야했다.

아마도 적절한 네임 스페이스 선언을 수행했지만 여전히 "요소"컨텍스트 : 구성 요소 스캔 "에 대한 접두사"컨텍스트 "가 바인딩되지 않은 오류에 직면했습니다." 비슷한 질문이 있지만 나는 대답을 얻지 못한다.

다음은 내 XML 문서입니다. 내 네임 스페이스가 올바르지 않습니까?

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    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/spring-context-3.0.xsd">



    <bean id="point1" class="org.sri.proj.Point">
        <property name="x" value="0" />
        <property name="y" value="0" />
    </bean>

    <bean id="point2" class="org.sri.proj.Point">
        <property name="x" value="10" />
        <property name="y" value="10" />
    </bean>

    <context:component-scan base-package="org.sri.proj"/>

</beans>

해결법

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

    1.컨텍스트 네임 스페이스 선언을 응용 프로그램 컨텍스트 파일의 beans 태그 정의에 추가합니다.

    컨텍스트 네임 스페이스 선언을 응용 프로그램 컨텍스트 파일의 beans 태그 정의에 추가합니다.

    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:context="http://www.springframework.org/schema/context"
        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">  
    
  2. ==============================

    2.예, 추가해야합니다.

    예, 추가해야합니다.

    http://www.springframework.org/schema/context
    

    전에

    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    

    그래서 그것은 다음과 같습니다.

    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:context="http://www.springframework.org/schema/context"
        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">
    
  3. ==============================

    3.컨텍스트 (http://www.springframework.org/schema/context) 네임 스페이스가 없습니다.

    컨텍스트 (http://www.springframework.org/schema/context) 네임 스페이스가 없습니다.

    <beans:beans xsi:schemaLocation="http://www.springframework.org/schema/mvc       http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd   
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd   
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd 
    
    
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
    

    이 코드의 마지막 줄을 추가하십시오.

  4. ==============================

    4.그런 다음 복사하고지나 가기 전에 헤더에 실제로 필요한 것이 무엇인지 살펴보십시오.

    그런 다음 복사하고지나 가기 전에 헤더에 실제로 필요한 것이 무엇인지 살펴보십시오.

    그래서 위의 구성 설정을 만족시키는이 작업을 수행하고

         <?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:mvc="http://www.springframework.org/schema/mvc"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/task
        http://www.springframework.org/schema/task/spring-task-3.2.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.2.xsd">
    
        <mvc:annotation-driven />
        <context:component-scan base-package="com.spring.study" />
        <bean
            class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix" value="/WEB-INF/jsp/" />
            <property name="suffix" value=".jsp" />
        </bean>
    
    </beans>
    

    건배! Dman!

  5. ==============================

    5.xmlns : context = "http://www.springframework.org/schema/context"를 추가해야합니다. 당신의 콩 xml에.

    xmlns : context = "http://www.springframework.org/schema/context"를 추가해야합니다. 당신의 콩 xml에.

  6. from https://stackoverflow.com/questions/16673644/contextcomponent-scan-is-not-bound by cc-by-sa and MIT license