하나의 생성자를 다른 생성자를 사용하려고 시도하는 것처럼 빈 생성에 대해 불평하는 레거시 코드가 있습니다.
org.springframework.beans.factory.UnsatisfiedDependencyException : class 경로 리소스 [catContext.xml]에 정의 된 이름이 'catService'인 Bean 생성 오류 : [boolean] 유형의 인덱스 0 인 생성자 인수를 통해 표현 된 종속성이 만족스럽지 않습니다. 생성자 인수 유형이 모호합니다. 생성자 인수로 올바른 빈 참조를 지정합니까?
빈의 XML 정의는 다음과 같습니다.
<bean id="catService" class="com.example.CatService" lazy-init="false">
<constructor-arg type="java.lang.String" value="${catName}" />
</bean>
catName
값은 다른 파일에서 가져 오며 다음은 폴더 구조입니다.
class 자체에는 여러 생성자가 있습니다.
@Autowired
public CatService(String catName) {
...
}
public CatService(){
...
}
public CatService(boolean isHungry){
...
}
Spring이 "잘못된"생성자를 사용하는 이유는 무엇입니까?