报的异常:Error creating bean with name 'girlController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'girlService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.example.demo.dao.TestDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}
2017-10-21 10:25:12.617 INFO 10544 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2017-10-21 10:25:12.632 INFO 10544 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-10-21 10:25:12.723 ERROR 10544 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
APPLICATION FAILED TO START
Description:
A component required a bean of type 'com.example.demo.dao.TestDao' that could not be found.
Action:
Consider defining a bean of type 'com.example.demo.dao.TestDao' in your configuration.
Process finished with exit code 1
这里接口换成普通类能够扫描到,但是变成jpa接口就扫描不到了
请问你这个问题解决了吗?
没有 百度很多方法 加上什么 @ComponentScan 也不管用
我也遇到这个问题,然后我在这说说我怎么排查的:
首先我也按照网上的解决办法进行的,我在启动类上加了如@EnableJpaRepositories @ComponentScan 这样的注解,
但是还是没用,后来仔细去看抛出来的异常,我发现在引用的spring-boot-starter-parent 和 spring-boot-starter-data-jpa 里面缺少了相应的jar包
在springboot启动的时候,加载spring-boot-starter-data-jpa时,spring-boot-starter-data-jpa中还依赖了其他的jar包,当系统扫描到没有那个jar包时,就会启动失败
所以你要具体去看那个报错里面出现了哪些依赖的jar包名称,然后一个个去看本地maven仓库中是否缺少了,然后把缺少的jar包补进去,就没问题了
温馨提示,在dao文件中最好加上@Repository注解