반응형

에러 메시지 :
org.springframework.beans.factory.NoSuchBeanDefinitionException:  No bean named 'XxxxxService' is defined 

원인 : Service 객체를 찾지 못하는 에러
1) Resource명과 Service명 불일치 or 어노테이션 정의 안됨
2) resource폴더가 deploy되지 않음
3) dispatcher-servlet.xml 설정 
4) 메이븐빌드 오류

해결 방법
1) XxxxImpl. java의 @Service("XxxxService")와 
XxxxController.java의 @Resource(name="XxxxService") 확인 (대소문자 구분)

2) 프로젝트 > Properties > Deployment Assembly 선택
Bold 표시 항목 추가
     Source                    |     Deploy Path
    /src/main/java               WEB-INF/classes
    /src/main/resource         WEB-INF/classes
    /src/main/webapp          /

3) context-common.xml 파일 확인
<context:component-scan base-package="egovframework">
  <context:include-filter type="annotation" expression="org.springframework.stereotype.Service"/>
  <context:include-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
  <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
 </context:component-scan> 
base-package는 내 패키지에 맞춰주고, Service와 Repository관련 annotation을 include

4) 프로젝트 clean, 메이븐 clean 
메이븐 빌드할때 goal에 "clean install war:inplace"

※ 평상시에 잘됐는데 갑자기 생기는 오류 일경우 4)일 가능성이 높음



반응형

+ Recent posts