inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

스프링 핵심 원리 - 기본편

옵션 처리

빈으로 등록하지 않았는데 @Autowired를 통해 의존성 주입할 때 충돌이 납니다.

869

작성자 없음

0

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

[질문 내용]
안녕하세요 @Autowired를 사용해 의존성 주입을 하다 충돌이 나서 질문드립니다.

MemberRepository인터페이스 -> MemoryMemberRepository 구현체

후자에만 @Component를 붙인 상황입니다.

그런데

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'memberServiceImpl' defined in file [/Users/minsung/Desktop/study/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

이런식으로 memberRepository 또한 빈으로 등록되어 있었습니다.

@Autowired가 클래스 타입으로 조회한다는 것은 알고 있지만 빈으로 등록되어있는 애들 중에서 조회하는 것 아닌가요...?

  1. 왜 memberRepository를 빈으로 등록하지 않았는데 빈으로 등록되어있는지

  2. @Autowired는 왜 빈으로 등록되지도 않은 memberRepository를 찾을 수 있었는지

  3. @Autowired 보다는 @RequiredArgsConstructor 사용을 권장하던데 이제 @Autowired는 잘 쓰이지 않는 것인지

궁금합니다!

spring 객체지향 @autowired 의존성주입 충돌

답변 3

0

pimoveh198

Academic success requires consistent effort, effective planning, and a clear understanding of different subjects. Students often have to balance classroom learning, examinations, projects, and personal responsibilities. Without proper organization, managing these tasks can become stressful. Developing good study habits and following a realistic schedule can help students stay focused and make steady progress toward their academic goals.

Students who struggle with difficult topics or complex writing tasks may also explore assignment help resources to understand assignment requirements, improve research techniques, and learn how to organize their ideas. Such resources can be useful for clarifying concepts and developing academic writing skills. Students should use the guidance responsibly and ensure that their submitted work reflects their own understanding.



0

Eddie Howe

목표는 각 레벨의 내러티브 목표에 맞게 캐릭터와 장면을 배치하는 것입니다. 각 퍼즐을 푸는 다양한 방법으로 창의성을 장려합니다. storyteller 에서 플레이어는 다양한 스토리텔링 경로를 탐색하고 진행하면서 고유한 스토리를 만들 수 있습니다. 게임의 복잡성이 증가함에 따라 각 레벨이 여전히 도전적으로 유지되어 플레이어의 전략적 사고와 문제 해결 능력에 대해 보상을 제공합니다.

0

orhamster

네, 저에게 강의 내용과 관련된 질문을 하셔도 됩니다. 강의 내용에 대해 궁금한 점이 있으시면 질문해 주세요. 제가 최대한 도움을 드리겠습니다.

tunnel rush

fieldInjectionTest() 질문

0

55

1

AutoAppConfig의 존재이유

0

49

1

AppConfig와 스프링 빈 질문

0

52

1

[영한님]Spring Boot 및 프로젝트 생성

0

117

2

퀴즈가 안열려요

0

104

2

회원 도메인 인터페이스 개발

0

110

2

빈 스코프 개념의 중요성

0

93

1

SingletonService가 JVM이 뜰 때 생성되는게 맞나요?

0

150

2

섹션3. 11 회원객체 다이어그램

0

81

1

OCP, DIP과 @Qualifier 어노테이션에 대해서 질문합니다.

0

77

1

코드 자료

0

137

2

구현체가 동적으로 정해질 때, 팩토리 기법을 사용하나요?

0

133

2

MemberService의 인터페이스를 왜 사용하는지 궁금합니다.

0

147

1

롬복 @Setter를 써야 하는 상황이 있는건가요?

0

144

1

빈 등록 메서드의 파라미터가 빈이 아니어도 되나요?

0

137

1

테스트 속도가 나중에 영향이 있을까요?

0

127

1

gradle 설정 안떠서 질문 남깁니다!

0

264

2

build.gradle로 프로젝트를 여는 이유

0

161

1

provider 사용하는 이유

0

163

1

다음 강의 뭘 들어야 할까요

0

192

2

프로토타입 빈, 직접 destroy 호출 안 할 경우

0

113

1

beanB

0

135

2

퀴즈다시풀기

0

109

1

Gradle로 바꿔도 오류가 똑같이 발생하네요 ㅠㅠ

0

163

2