에러 모음

NoSuchBeanDefinitionException, UnsatisfiedDependencyException

junani0v0 2024. 5. 23. 20:27

< 에러 메시지 >

SEVERE: Context initialized 이벤트를 [org.springframework.web.context.ContextLoaderListener] 클래스의 인스턴스인 리스너에 전송하는 동안 예외 발생

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'joinController': Unsatisfied dependency expressed through field 'joinService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'joinService': Unsatisfied dependency expressed through field 'memberRepository'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.portfolio.www.auth.mybatis.MemberRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

 

NoSuchBeanDefinitionException 

 - Spring이 해당 타입의 빈을 찾지못해 발생

 

UnsatisfiedDependencyException

 - 의존성 주입시 빈을 찾을 수 없거나, 여러개의 빈이 주입 대상에 대해 일치하는 경우 발생

< 원인 >

<!-- DAO 위치를 basePackage로.. -->
<!-- 작업지시서가 있는 패키지 위치를 잡아줘야 사용 할 수 있다 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="com.pf.www.forum.notice.dao.mybatis" />
</bean>

context-bean에서 경로설정을 변경해주지 않아 
com.portfolio.www.auth.mybatis.MemberRepository 의 bean을 못찾음

< 해결 >

<!-- DAO 위치를 basePackage로.. -->
<!-- 작업지시서가 있는 패키지 위치를 잡아줘야 사용 할 수 있다 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="com.portfolio.www.auth.mybatis" />
</bean>

경로를 알맞게 재설정하여 해결

'에러 모음' 카테고리의 다른 글

[Spring Framework] UnsatisfiedDependencyException  (0) 2024.05.29
ServletException  (0) 2024.05.23
[java]JasperException  (0) 2024.05.17
NullPointerException  (0) 2024.05.17
IllegalArgumentException  (0) 2024.05.17