Recently, I encountered a bug in my work.
the project uses springboot, and uses springcontexthloder, getBean (); No qualifying bean of type ‘xxx’ available
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.tension.web.disabledevaluate.service.DisabledEvaluateService' available
Generally, this error indicates that there is no bean available. Check the code carefully to ensure that this class exists and is injected into spring correctly
Controller:
public Map loadForm(String round,String instanceId) {
//error
DisabledEvaluateService disabledEvaluateService = SpringContextHolder.getBean(DisabledEvaluateService.class);
}
Service:
@Service
@Transactional(readOnly = true)
public class DisabledEvaluateService extends CrudService<DisabledEvaluateDao, DisabledEvaluate> {
public DisabledEvaluate getByBjId(Map map){
return dao.getByBjIdOrInstanceId(map);
}
After several hours of exploration, we finally found the information on the Internet because we used the devtools hot deployment plug-in. As a result, when the program starts, we use the classloader rewritten by the devtools hot deployment plug-in instead of the Java default classloader. As a result, some classes may not be loaded correctly, resulting in the inability to obtain beans.
Solution:
this error can be solved without using hot deployment plug-in
Read More:
- [Solved] Springboot Startup Error: Consider defining a bean of type ‘XXX’ in your configuration.
- [Solved] SpringBoot Project Start Error: No bean named ‘org.springframework.context.xxxxx.importRegistry‘ available
- [Solved] Springboot Error creating bean with name ‘dataSource’ defined in class path resource
- Eureka unit test error creating bean with name ‘Eureka autoservice registration’: Singleton bean
- AOP Error Cannot resolve reference to bean ‘txPointCut‘ while setting bean property ‘po
- [Solved] SpringBoot Integrates Swagge Error: Failed to start bean ‘documentationPluginsBootstrapper‘
- SpringBoot High Version Import Swagger 2.9.2 Error: ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper‘
- SpringBoot Access Clickhouse Error: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘jdbcConverter’ defined in class path resource [***.class]
- [Solved] “Field pet in XXX.HelloController required a bean of type ‘XXX.Pet‘ that could not be found.“
- [Solved] Springboot integrate Seata Error: error creating bean with name ‘globaltransactionscanner’‘
- [Solved] hytrix service degraded bean cannot inject error
- [Solved] Notwritablepropertyexception: invalid property ‘mapperhelper’ of bean class
- [Solved] Error creating bean with name rController‘: Unsatisfied dependency expressed through field
- [Solved] org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dataSource‘
- [Solved] UnsatisfiedDependencyException: Error creating bean with name
- [Solved] AOP Error: BeanPostProcessor before instantiation of bean failed
- Error creating bean with name ‘studentMapper‘ defined in file
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘globalTransa
- [Solved] Error creating bean with name ‘sqlSessionFactory‘ defined in class path resource
- [Solved] renren-fast Startup Error: Error creating bean with name ‘scheduleJobController‘