定义类型的 bean 时出现问题

Issue in defining a bean of type

我尝试通过使用注释 @Repository 扩展 CRUD 存储库来创建接口。我还尝试使用 Auto wired annotation 在 Service class 中使用接口函数。但是我面临下面给出的问题

***************************
APPLICATION FAILED TO START
***************************

Description:

Field bookRepository in com.example.service.BookService required a bean of type 'com.example.repo.BookRepository' that could not be found.

The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'com.example.repo.BookRepository' in your configuration.

项目结构如下:

问题出在您的项目结构上。尝试替换以下所有其他包:

com.example.learn 

在上面之后,您将不需要 @ComponentScan 和 @Repository,因为 @SpringBootApplication 会处理它。