작성
·
2.2K
0
2021-05-14 17:38:16.796 WARN 21720 --- [ main] o.s.w.c.s.GenericWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [jpabook.jpashop.JpashopApplication]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'memberRepository' for bean class [jpabook.jpashop.repository.MemberRepository] conflicts with existing, non-compatible bean definition of same name and class [jpabook.jpashop.MemberRepository]
JUNIT 테스트 실행하니 위와 같은 에러로 테스트가 진행이 되지 않는데요..
콘솔 로그로 보았을 땐 동일 이름의 bean 이 존재한다고 하는데.. 어딜 수정해야ㅏ할지 모르겠네요..
혹시 어느 부분을 수정해야 하는지 알 수 있을까요?
\
소스코드도 같이 첨부드립니다..
package jpabook.jpashop.service;
import jpabook.jpashop.domain.Member;
import jpabook.jpashop.repository.MemberRepository;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import static org.junit.Assert.*;
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class MemberServiceTest {
@Autowired
MemberService memberService;
@Autowired
MemberRepository memberRepository;
@Test
public void 회원가입() throws Exception {
//given
Member member = new Member();
member.setName("memberA");
//when
Long savedId = memberService.join(member);
//then
assertEquals(member, memberRepository.findOne(savedId));
}
}
답변 1
1
안녕하세요. illhumored님
오류 메시지를 읽어보면, 현재 MemberRepository가 2개 있다고 합니다.
jpabook.jpashop.repository.MemberRepository
jpabook.jpashop.MemberRepository
아래 클래스는 삭제해주세요.
감사합니다.