no entity!!!!! 분명 애플리케이션 환경에서는 잘 돌아가는데, test 코드에서는 왜 찾지 못하는것인가
아직 부족한 부분이 많다보니 내가 모르는 엔티티 적용 방법이 있는건지 계속 고민했다 ㅠㅠ
그때 블로그 참고 해서 다행이 해결했는데
@EnableJpaRepositories 어노테이션을 써서 repository의 위지를 명시적으로 지정해준다.
혹은
@ActiveProfiles("test") 환경을 지정해준다.
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'a.b.c.MyRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
@DataJpaTest
@EnableJpaRepositories("someThing")
public class WinnerRepository{
해당 클래스를 가서 context 주입이 되어있는지 확인한다. 어노테이션을 적용해줬다면 해당 엔티티 클래스를 찾지 못해서 발생한 에러이다.
이럴때는 @EntityScan 어노테이션을 써서 명시적으로 엔티티 클래스 위치를 지정해준다
@EntityScan("a.b.c")
Caused by: java.lang.IllegalArgumentException: Not a managed type: class a.b.c.My
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) 해당 어노테이션으로 강제 대체를 막으면 application.properties yml에 설정된 DB로 연결할 수 있다.
javax.persistence.NoResultException: No entity found for query
[ main] o.s.j.d.e.EmbeddedDatabaseFactory : Starting embedded database: url='jdbc:h2:mem:09aea81c-0755-4351-b31e-7f60171664e4;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false', username='sa'