상황 : 기존 프로젝트 안에 이름만 다른 같은 구현내용의 패키지 생성

게시판 리스트를 보여주는 MVC 패키지 작성

기존 Board : controller, bean. mybatis, service 모델 패키지

새로만든 Aboard : controller, bean. mybatis, service 모델 패키지

에러 발생

번역해도 무슨 뜻인지 잘 모르겠다.

하루 통을 날리고 다시 패키지 만들고 잘 클론 코딩 하고 부족한 부분 찾아봄.

                            <에러전문>
WARN : org.springframework.web.context.support.XmlWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: 컨텍스트 초기화 중 예외가 발생했습니다. org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ATeamServiceImpl': Unsatisfied dependency expressed through field 'mapper'; '매퍼' 필드를 통해 표현된 충족되지 않은 종속성; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'a.team.mybatis.AboardMapper' available: 사용 가능한 'a.team.mybatis.AboardMapper' 유형의 적합한 빈이 없습니다. expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: autowire 후보에 해당하는 최소한 1개의 bean이 필요합니다. 종속성 주석 {@org.springframework.beans.factory.annotation.Autowired(required=true)} ERROR: org.springframework.web.context.ContextLoader - Context initialization failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ATeamServiceImpl': Unsatisfied dependency expressed through field 'mapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'a.team.mybatis.AboardMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'a.team.mybatis.AboardMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

해법

root-context.xml에   

<mybatis-spring:scan base-package="org.mvc.mybatis" /> <<기존
<mybatis-spring:scan base-package="a.team.mybatis" /> <<추가(어제 했던거 같은데.. 하두 뇌절이 와서 기억도 안남..)

mybatis 어노테이션을 스캔해주고 mybatis 인터페이스를 스캔해서 구현해준다. 

+ Recent posts