작성
·
221
0
MemberService memberService = new MemberService();
MemoryMemberRepository memberRepository = new MemoryMemberRepository();
MemberService memberService;
MemoryMemberRepository memberRepository;
@BeforeEach
public void beforeEach(){
memberRepository = new MemoryMemberRepository();
memberService = new MemberService(memberRepository);
}
private final MemoryMemberRepository memberRepository;
public MemberService(MemberRepository memberRepository){
this.memberRepository = memberRepository;
}
답변 1
0
MemberService.java 의 memberRepository 선언부분을
private final MemberRepository memberRepository 로 수정해보세요.
하위 타입의 참조변수가 상위 타입의 인스턴스를 참조할 수 없습니다.
해결됐습니다. 답변 감사합니다.