jeudi 19 novembre 2020

No qualifying repository test in Spring

I'm using Spring 2.4 and jUnit 5.7 I'm trying to use a repository create for test but I'm getting "No qualifying bean of type".

I annotated the repository @TestComponent.

package com.cjgmj.dynamicQuery.persistence.repository;

import org.springframework.boot.test.context.TestComponent;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import com.cjgmj.dynamicQuery.persistence.entity.DummyEntity;

@TestComponent
public interface DummyRepository extends JpaSpecificationExecutor<DummyEntity> {

}

And I'm trying to get it on my Test class.

@SpringBootTest
public class TextLikeSpecificationTests {

    @Autowired
    private DummyRepository dummyRepository;

    ...

}

The project structure is:

- src/test/java  
|- projectPackage  
  |- persistence
    |- entity
      |- DummyEntity
    |- repository
      |- DummyRepository

I tried place the repository and the entity on main package, and also without annotation in the repository, but I'd got the same error.What I'm doing wrong?

Thank you in advance.

Aucun commentaire:

Enregistrer un commentaire