严重: Exception sending context initialized event tolistener instance of classorg.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException:Error creating bean with name 'searchDao': Injection of autowired dependenciesfailed; nested exception isorg.springframework.beans.factory.BeanCreationException: Could not autowirefield: private org.apache.solr.client.solrj.SolrServercn.e3mall.search.dao.SearchDao.solrServer; nested exception isorg.springframework.beans.factory.NoUniqueBeanDefinitionException: Noqualifying bean of type [org.apache.solr.client.solrj.SolrServer] is defined:expected single matching bean but found 2: httpSolrServer,cloudSolrServer
atorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
atorg.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
atorg.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
atorg.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
atorg.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
atorg.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
atorg.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
atorg.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
atjava.util.concurrent.FutureTask.run(FutureTask.java:266)
atjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
atjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
atjava.lang.Thread.run(Thread.java:745)
Caused by:org.springframework.beans.factory.BeanCreationException: Could not autowirefield: private org.apache.solr.client.solrj.SolrServercn.e3mall.search.dao.SearchDao.solrServer; nested exception isorg.springframework.beans.factory.NoUniqueBeanDefinitionException: Noqualifying bean of type [org.apache.solr.client.solrj.SolrServer] is defined:expected single matching bean but found 2: httpSolrServer,cloudSolrServer
atorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
atorg.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
atorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
...22 more
Caused by:org.springframework.beans.factory.NoUniqueBeanDefinitionException: Noqualifying bean of type [org.apache.solr.client.solrj.SolrServer] is defined:expected single matching bean but found 2: httpSolrServer,cloudSolrServer
atorg.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1126)
atorg.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
atorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
...24 more
解决方案:
solr配置文件中写了两个bean注入单机版和集群版,注释掉一个就可以了