No qualifying bean of type 'com.yubai.bean.BeanWayService' available
2017-08-13 13:30
579 查看
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'useBeanWayService': Unsatisfied dependency expressed through field 'beanWayService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.yubai.bean.BeanWayService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} Exception in thread "main" org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'useBeanWayService': Unsatisfied dependency expressed through field 'beanWayService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.yubai.bean.BeanWayService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:84) at com.yubai.bean.MainBean.main(MainBean.java:7) Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.yubai.bean.BeanWayService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1493) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585) ... 14 more Process finished with exit code 1
以上错误的导致原因是由于beanWayService这个bean没被注入到spring容器中。所以解决办法就是添加@Bean到beanWayService()方法上,如下图所示:
相关文章推荐
- No qualifying bean of type 'com.yubai.el.ELConfig' available
- FAQ(54):No qualifying bean of type 'com.Role.Service.RoleService' available: expected at least 1 bea
- No qualifying bean of type 'com.funo.oa.dao.PostDao' available问题解决:找不到dao的实现类
- No qualifying bean of type [com.shyy.web.service.TreeMapper] found for dependency
- No qualifying bean of type [com.zc.service.IFancyService] found for dependency
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.oskyhang.gbd.service.UserService] found for dependency: expected at least 1 bean which qualifies as aut
- No qualifying bean of type [com.it.service.DeptService] found for dependency
- NoSuchBeanDefinitionException: No qualifying bean of type 'net.shopxx.service.xxxService' available:
- NoSuchBeanDefinitionException: No matching bean of type [com.piesat.web.service.SelectItemsService]
- No qualifying bean of type [com.*.*.dao.InfoDao] found for :错误!
- ###No qualifying bean of type [cn.e3.manager.service.ItemCatService] ,web注入service失败
- spring容器无法注入service(No qualifying bean of type)
- No qualifying bean of type [com.hz.app.mgmt.system.mgr.SysComBaseSettingMgr] is defined
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.cui
- MyBatis映射错误,No qualifying bean of type 'xx.xx.UserDao' available
- 出现No qualifying bean of type [com.*.*.dao.InfoDao] found for :错误
- No matching bean of type [com.spw.service.UserService] found for dependency
- No qualifying bean of type 'org.apache.catalina.User' available
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.wan
- No qualifying bean of type [com.jj.mapper.UserMapper] found for dependency