에러 모음

UnsatisfiedDependencyException, NoSuchBeanDefinitionException

junani0v0 2024. 4. 19. 22:55

< 에러 메시지 >

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'loginController': Unsatisfied dependency expressed through field 'joinService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.join01.www.service.JoinService' available: expected at least 1 bean which qualifies as autowire candidate.

 

< 원인 >

UnsatisfiedDependencyException : 의존성 불만족 예외

NoSuchBeanDefinitionException : 빈 정의 없음 예외

 

loginController' 빈을 생성하는 과정에서 발생했습니다. 해당 빈 내부에서 'joinService' 필드를 주입하려고 했는데, 'com.join01.www.service.JoinService' 타입의 빈이 존재하지 않아서 주입에 실패

 

< 해결 >

pf-servlet에 Controller처럼 자동 bean을 등록해 줌

<context:component-scan
    base-package="com.join01.www" use-default-filters="false">
    <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>

<context:component-scan
    base-package="com.join01.www" use-default-filters="false">
    <context:include-filter type="annotation" expression="org.springframework.stereotype.Service" />
</context:component-scan>