강의

멘토링

로드맵

Inflearn Community Q&A

wltn120473232136's profile image
wltn120473232136

asked

Spring Core Principles - Basic Edition

Option Processing

CoreApplicationTests 오류

Resolved

Written on

·

1.5K

·

Edited

2

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.

1. 강의 내용과 관련된 질문을 남겨주세요.
2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.
(자주 하는 질문 링크: https://bit.ly/3fX6ygx)
3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.
(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)

질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.
=========================================
[질문 템플릿]
1. 강의 내용과 관련된 질문인가요? (예)
2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예)
3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)

[질문 내용]

CoreApplicationTests 부분에서 오류가 나는데 강사님과는 다른 오류가 나서 질문 드립니다.

 

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'memberServiceImpl' defined in file [D:\core\core\out\production\classes\hello\core\member\MemberServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0: No qualifying bean of type 'hello.core.member.MemberRepository' available: expected single matching bean but found 2: memoryMemberRepository,memberRepository

 

memoryMemberRepo를 매칭해야 하는데 2개가 존재해서 그런 것 같은데(맞는지는 잘 모르겠습니다)

MemberService에는 아무런 Annotation도 붙이지 않았는데 왜 그런 걸까요?

 

(작성한 코드 이미지 첨부합니다)

 

Snipaste_2023-12-05_00-19-59.png

Snipaste_2023-12-05_00-21-16.png

  • 추가

Appconfig 의 @Bean 이 붙은 메소드에 모두 @Primary를 붙여서 어찌저찌 해결은 했는데

무슨 이유로 저 오류가 나는건지 궁금합니다

spring객체지향

Quiz

66% of people got it wrong. Give it a try!

What are the main reasons why Field Injection is generally not recommended?

Because it is difficult to guarantee immutability

Because changing dependencies is easy

Because it's difficult to test with pure Java code

Because writing configuration code is complex

Answer 2

3

안녕하세요 저도 똑같은 문제를 겪었는데 아무래도 @SpringbootApplication이 @ComponentScan을 가지고 있어서 AutoAppConfig에서 막는다고 해도 결국 AppConfig가 읽히는 것같아요

wltn12047323님의 프로필 이미지
wltn12047323
Questioner

감사합니다! 저만 그런게 아니었군요...

네네ㅠㅜ 근데 일단 @SpringbootApplication이 AppConfig를 읽는것같다는건 제 뇌피셜이라서(?) 다른 이유가 있으면 공유해요!

1

안녕하세요. wltn12047323님, 공식 서포터즈 David입니다.

스프링부트 최신버전과 관련되어 발생하는 문제로 보여집니다.

아래 글 답변을 참고 부탁드립니다.

https://www.inflearn.com/questions/1089023

감사합니다.

wltn12047323님의 프로필 이미지
wltn12047323
Questioner

감사합니다!

wltn120473232136's profile image
wltn120473232136

asked

Ask a question