코딩항해기
[Error/Spring] NoSuchBeanDefinitionException (xml 어노테이션 설정 문제) 본문
Error solution
[Error/Spring] NoSuchBeanDefinitionException (xml 어노테이션 설정 문제)
miniBcake 2024. 10. 4. 11:43
기존 xml bean 태그로 작업하다 어노테이션으로 변경했더니 bean을 찾지 못하는 에러가 발생했다.
xml에서 어노테이션을 인지할 수 있도록 총 2가지의 작업을 해야하는데, 범위지정이 빠져 발생한 오류였다.
기존 루트 앨리먼트
<?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.xsd">
어노테이션을 인지할 수 있도록 변경한 루트 앨리먼트
<?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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd">
어노테이션을 찾을 범위를 지정해주는 태그
*test패키지 안에 있는 파일에서 어노테이션을 찾겠다는 설정이다. (해당 태그가 빠져 오류 발생)
<context:component-scan base-package="test" />
'Error solution' 카테고리의 다른 글
[Error/Spring] MySQL Connection Error (0) | 2024.10.05 |
---|---|
[Error/Spring] UnsatisfiedDependencyException (0) | 2024.10.04 |
[Error/MySQL] DBeaver 계정연결 Public Key Retrieval is not allowed (0) | 2024.10.03 |
[Error/WebDriver] NoClassDefFoundError: .../selenium/WebDriver (0) | 2024.09.12 |
[Error/GoogleOAuth] 구글 OAuth 빈 팝업 (localhost:포트번호 사용 시) (0) | 2024.09.11 |