Spring: root-context.xml 에러

 

Spring의 root-context.xml을 수정하다가 context:component-scan 태그에 오류가 발생했다.

 

 

① 첫 번째 에러

The prefix "context" for element "context:component-scan" is not bound.

: beans의 xmlns 선언 부분에 context에 대한 부분이 없어서 발생하는 에러이다.

 

아래와 같이 xmlns:context="http://www.springframework.org/schema/context" 를 추가해주면 해결된다!

 

그렇지만, 새로운 에러 메세지가 생겼다!

② 두 번째 에러

cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component- scan'.

 

저 에러는 선언을 찾을 수 없다는 문구라고 한다.

그래서 하단의 namespace를 클릭한다.

 

왼쪽에 context를 체크하고 우측에서 default 부분을 체크하고 cmd(또는 ctrl) + s로 저장한다.

 

 

드디어 에러가 사라졌다!!

 

 

바뀌기 전후를 비교하면 선언부가 추가된 것을 확인할 수 있다.

 

Before

After

 

 

 

해결완료!

 

 

 


 

참고사이트

https://hsunnystory.tistory.com/201

https://blockcahin.tistory.com/128