• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

QuickMapper를 찾을 수 없다는 오류가 뜹니다. @Autowired 사용에 문제가 있는 걸까요?

24.04.03 11:25 작성 24.04.03 12:24 수정 조회수 83

1

안녕하세요?

강의 내용이 너무 좋아서 빠져서 듣고 있습니다.

그런데 mybatis연결 과정에서 QuickMapper interface와 xml연결하는 부분 수업 중에 아래와 같은 에러가 발생했습니다.

 

에러 내용만 보면 Service 에서 QuickMapper를 @Autowired하는 부분부터 문제가 생기는 것 같은데 해결방법을 모르겠습니다.

현재 에러가 나는 상태로 git에 소스 올려두었습니다.
https://github.com/ljpson/quickstart.git

에러 내용은 아래와 같습니다.

 

2024-04-03T11:20:24.392+09:00 WARN 74964 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'quickController': Unsatisfied dependency expressed through field 'quickService': Error creating bean with name 'quickService': Unsatisfied dependency expressed through field 'quickMapper': No qualifying bean of type 'com.helloworld.quickstart.mapper.QuickMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

2024-04-03T11:20:24.395+09:00 INFO 74964 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]

2024-04-03T11:20:24.404+09:00 INFO 74964 --- [ main] .s.b.a.l.ConditionEvaluationReportLogger :

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.

2024-04-03T11:20:24.418+09:00 ERROR 74964 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :

***************************

APPLICATION FAILED TO START

***************************

Description:

Field quickMapper in com.helloworld.quickstart.service.QuickService required a bean of type 'com.helloworld.quickstart.mapper.QuickMapper' that could not be found.

The injection point has the following annotations:

- @org.springframework.beans.factory.annotation.Autowired(required=true)

Action:

Consider defining a bean of type 'com.helloworld.quickstart.mapper.QuickMapper' in your configuration.

Process finished with exit code 1

 

답변 1

답변을 작성해보세요.

1

해결되었습니다.

dependency 추가할 때
mybatis-spring-boot-starter를 추가해야 하는데

mybatis를 추가했었네요ㅠ.ㅠ

 

창피해서 질문 삭제할까 하다가

혹시라도 저처럼 삽질하시는 분 계실까봐 답글로 마무리합니다.

좋은 경험 하신겁니다.

xxx-starter 로 된 의존성을 넣어줘야 자동으로 bean 으로 등록해줍니다.

다들 처음할 때 이런 실수를 많이 하는데 좋은 질문과 답변입니다.