I am trying to put an integration test for my JPA repository defined as
@Repository
public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificationExecutor<Task> {
@Query("SELECT r from Task r where r.user.id = :userId AND r.date >= :startDate AND r.date <= :endDate")
List<Task> getTasksBetweenDates(@Param("userId") long userId, @Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate);
}
I put a test as follows:
@ExtendWith(SpringExtension.class)
@DataJpaTest
public class TaskRepositoryIntegrationTest {
@Autowired
private TaskRepository taskRepository;
<test methods>
}
However, IntelliJ complains "Could not autowire. No beans of TaskRepository type found".
Can someone advise?
EDIT: The error message is:
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test