2014-09-17 7 views
2

저는 포털 프로젝트 작업을하고 있습니다. 포틀릿을 WebSphere에 배치 할 때 NoSuchBeanDefintionException을 얻었으며 component-scan 패키지를 확인하고 그에 대해 봤지만 어떤 해결책도 찾지 못했습니다. 모든 포틀릿의 context.xml에있는 모든 필수 패키지해당 bean 정의가 없습니다.

내가 구성 요소 검사에 필요한 모든 패키지를 추가 한 로그

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.myhealthone.common.model.Account com.hca.cpp.coreservice.UserServiceImpl.account; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.myhea.common.model.Account] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@ringframework.beans.factory.annotation.Autowired(required=true)} 
> at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcesva:514) 
> at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) 
> at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor285) 
     ... 147 more 
> Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.myhealthone.common.model.Account] found for depy: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotatiowired(required=true)} 

아래를 참조하십시오.

+1

'com.myhea.common.model.Account' 당신은'Service' 또는'Resource' 등과 같은 모든 고정 관념이 클래스에 주석을 했습니까? –

+0

이 문제가 해결 되었습니까? 그렇다면 어떻게 해결 했습니까? – Xstian

답변

1

this link에서 스프링 2.5은 더 스테레오 타입 주석을 소개 : @Component, @Service와 @Controller를. @Component는 모든 스프링 관리 구성 요소에 대해 일반 스테레오 타입 으로 사용됩니다. 반면 @Repository, @Service 및 @Controller는 구체적인 사용 사례 (예 : 지속성, 서비스 및 프리젠 테이션 계층에서 각각 )에 대해 @Component의 특수화 역할을합니다. 이것이 의미하는 바는 구성 요소 클래스에 @Component 주석을 달 수 있지만 대신 @Repository, @Service 또는 @Controller로 주석을 달아 클래스가 더 적절하게 도구로 처리하거나 애스펙트와 연결하는 데 적합합니다. 예제의 경우 이러한 스테레오 타입 주석은 포인트 컷에 대한 이상적인 타겟을 만듭니다. 물론 @Repository, @Service, 및 @Controller가 스프링 프레임 워크 의 향후 릴리스에서 추가 의미를 전달할 수도 있습니다. 따라서 서비스 레이어에 대해 @Component 또는 @Service를 사이에서 사용하기로 결정하는 경우 @Service는 분명히 입니다. 마찬가지로 위에서 설명한 것처럼 @Repository는 지속성 계층에서 자동 예외 변환의 마커로 이미 으로 지원됩니다.

<?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.xsd"> 

    <context:component-scan base-package="org.example"/> 

</beans> 

@Service 
public class SimpleMovieLister { 

    private MovieFinder movieFinder; 

    @Autowired 
    public SimpleMovieLister(MovieFinder movieFinder) { 
     this.movieFinder = movieFinder; 
    } 
} 

@Repository 
public class JpaMovieFinder implements MovieFinder { 
    // implementation elided for clarity 
} 
관련 문제