SpringBoot使用Elasticsearch却扫描不到Repository

在使用spring-data进行ES操作的时候,报找不到Repository错误

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-07-06 18:34:07.085 ERROR 2364 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :

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

Description:

Field bookRepository in com.xxximpl.BookServiceImpl required a bean of type 'com.xxximpl.repository.BookRepository' that could not be found.


Action:

Consider defining a bean of type 'com.xxximpl.repository.BookRepository' in your configuration.


Process finished with exit code 1

解决办法就是在启动类加上@EnableElasticsearchRepositories(basePackages = “com.xxximpl.repository”)