我正在为我的应用程序使用spring boot和spring数据mongodb。我有一个扩展MongoRepository的接口,例如:
public interface CardsRepository extends MongoRepository<Card, String>
我在服务类中使用该存储库,如下所示:
private CardsRepository cardsRepository;
@Autowired
public CardsServiceImpl(CardsRepository cardsRepository) {
this.cardsRepository = cardsRepository;
}
但是当我运行代码时,出现以下错误:
Description:
Parameter 0 of constructor in *.*.*.service.CardsServiceImpl required a bean of type '*.*.*.repository.CardsRepository' that could not be found.
Action:
Consider defining a bean of type '*.*.*.repository.CardsRepository' in your configuration.
I have tried annotating my Repository interface with @Repository but to no success.