Bean creation exception on FactoryBean type check: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name xxx
spring bean创建失败
我的是ssm项目,项目已启动就报错,mapper接口和mapper的配置文件放在了两个文件夹下,导致创建失败
sending contextinitialized event to listener instance of classorg.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException:Error creating bean with name 'itemServiceImpl': Injection of autowireddependencies failed; nested exception isorg.springframework.beans.factory.BeanCreationException: Could not autowirefield: org.apache.solr.client.solrj.SolrServercom.taotao.search.service.impl.ItemServiceImpl.solrServer; nested exception isorg.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifyingbean of type [org.apache.solr.client.solrj.SolrServer] found for dependency:expected at least 1 bean which qualifies as autowire candidate for thisdependency. Dependency annotations:{@org.springframework.beans.factory.annotation.Autowired(required=true)}
itemServieImpl代码:
![](https://i-blog.csdnimg.cn/blog_migrate/02fced8f847d0a1592d08ec1780fdedc.png)
![](https://i-blog.csdnimg.cn/blog_migrate/05aa63cbdc9363f761019838d96b49f7.png)
再次看报错,向前看是spring的context初始化出错,那么什么时候加载spring容器的呢?
自然,这得看web.xml
![](https://i-blog.csdnimg.cn/blog_migrate/1b7a1ae6b13b9acfb81c62f7f3ba51ce.png)
重点是这里加载spring容器只是将spring/下面的所有applicationContext-*.xml文件加载
但是我的solr是这样的
![](https://i-blog.csdnimg.cn/blog_migrate/a33ef2dd511f54f1632fcaeda4670a30.png)
![](https://i-blog.csdnimg.cn/blog_migrate/02c66c82d77e15ac7411b58e2cf2f2de.png)