반응형

이 문제는 Bean을 생성하면서, 제대로 Bean을 생성하지 못해 발생하는 에러 메시지다.

 

No qualifying bean of type 'com.util.TestServiceUtil' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 

 

위의 문제는 아래와 같이 설정을 했을 때 거의 나올 것이다.

 

public class TestApiService extends TestService {

	@Autowired
	private Test2Service test2Service;
}

 

위의 코드와 같이, 다른 서비스나 컨트롤러 단에서 Test2Service.java에 대해 서비스를 사용할 경우 위와 같이 Autowired를 통해 Bean을 주입한다. 근데, 여기서만 @Autowired를 주입하고 Test2Service에서는 따로 애노테이션을 정의하지 않아 발생하는 오류다. 즉, @Autowired를 쓰려면 @repository, @Service, @Component 등을 걸어줘야 가져간다.

 

그래서, 저 Test2Service 위에 @Service 애노테이션을 정의하니 에러가 해결됐다.

반응형
  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기