2020-07-15 14:09:28.821 WARN 11732 — [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘genController’: Unsatisfied dependency expressed through field ‘iGenTableService’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘genTableServiceImpl’: Unsatisfied dependency expressed through field ‘genTableRepository’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.bella.dao.GenTableRepository’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-07-15 14:09:29.199 ERROR 11732 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field genTableRepository in com.wondersgroup.healthcloud.service.impl.GenTableServiceImpl required a bean of type 'com.wondersgroup.healthcloud.dao.GenTableRepository' 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.wondersgroup.healthcloud.dao.GenTableRepository' in your configuration.
两个Bean的定义都没问题 , 但是 GenTableServiceImpl 却无法在Spring容器中找到 GenTableRepository 这个Bean 。
注意 : 我们使用的是JpaRepository (spring-data-jpa)的功能 , 可能是项目框架中没有定义 JpaRepository 扫描包的位置 或 定义的位置和我们Class的位置不一致导致我们的 Bean 无法的注入到 Spring 容器中。
## 指定JpaRepositry扫描包的位置
@EnableJpaRepositories(basePackages = {"com.bella.dao.repository", "com.bella.dao"})
## 扫描的包可以定义多个 , basePackages 是一个 String 数组 (一定要保证你的Reposity在扫描路径中)
## 如果项目中没有定义 @EnableJpaRepositories , 可以在Application启动类上添加此注解 (或者自己定义一个 JpaConfig Bean 也可以)
## 指定Entity的扫描位置 (如果不指定 Entity Bean 也无法使用)
@EntityScan(basePackages = { "com.bella.domain" })
本文地址:https://blog.csdn.net/qq_24958783/article/details/107359799
如对本文有疑问, 点击进行留言回复!!
Mybatis PersistenceException异常:Error building SqlSession The error may exist in SQL Mapper Configur
MyBatis——动态SQL语句——if标签和where标签复合使用
网友评论