如何修复JAVA spring boot中的“​​考虑定义类型的bean”错误?

时间:2019-07-16 05:51:34

标签: spring-boot java-8 spring-data spring-data-mongodb

我正在为我的应用程序使用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.

0 个答案:

没有答案