本文介绍了具有Solr 4.1多核的Spring Data Solr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    Trying to implement Spring-Data-Solr with Solr 4.1 multicores,

在服务器启动时,出现以下异常,我猜它期望某个地方有默认构造函数.那么,使用solr muticores实现的spring-data-solr是否有限制,这是我的实现,

At server startup getting following exception, I guess it expecting a default constructor somewhere. So, is there a limitation of spring-data-solr with solr muticores implementation, here is my implementation,

    public interface MembershipDocumentRepository extends
            CustomMembershipDocumentRepository,
            SolrCrudRepository<MembershipDocument, String> {
    }


 created 'repository' manually instead of autowiring/injection.......

    @Service
    public class RepositoryMembershipIndexService implements MembershipIndexService {
        @Autowired
        private SolrTemplate solrMembershipTemplate;

        private MembershipDocumentRepository repository = new SolrRepositoryFactory(
                this.solrMembershipTemplate)
                .getRepository(MembershipDocumentRepository.class);

        @Transactional
        @Override
        public void addToIndex(Membership membershipEntry) {
            MembershipDocument document = MembershipDocument.getBuilder(
                    ...
            repository.save(document);
        }
    }

applicationContext-solr.xml

        <solr:repositories
            base-package="net.pegonwheels.spring.datasolr.domain.repository.solr" />
        <beans profile="prod">
            <solr:solr-server id="solrMembershipServer" url="${solr.server.url.membership}" />
            <bean id="solrMembershipTemplate" class="org.springframework.data.solr.core.SolrTemplate">
                <constructor-arg ref="solrMembershipServer" />
            </bean>
        </beans>

例外

    At server startup getting following exception, I guess it expecting a default constructor somewhere. So, is there a limitation of spring-data-solr with solr muticores implementation. Can somebody please help me, thanks a ton in advance.

org.springframework.beans.factory.BeanCreationException:创建文件[/home/rupanjan/Installations/apache-tomcat-7.0.39/webapps/pegonwheels-server/WEB-INF/[类/net/pegonwheels/spring/datasolr/domain/service/RepositoryMembershipIndexService.class]:实例化Bean失败;嵌套的异常是org.springframework.beans.BeanInstantiationException:无法实例化bean类[net.pegonwheels.spring.datasolr.domain.service.RepositoryMembershipIndexService]:构造方法抛出了异常;嵌套的异常是java.lang.IllegalArgumentException:[断言失败]-此参数是必需的;否则为false.它不能为空 在org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:306)处 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1120) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)处 在org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:295) 在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) 在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) 在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) 在org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607) 在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)处 在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) 在org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383) 在org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) 在org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) 在org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887) 在org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381) 在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 在org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) 在org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) 在org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) 在org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977) 在org.apache.catalina.startup.HostConfig $ DeployWar.run(HostConfig.java:1655) 在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:439) 在java.util.concurrent.FutureTask $ Sync.innerRun(FutureTask.java:303) 在java.util.concurrent.FutureTask.run(FutureTask.java:138) 在java.util.concurrent.ThreadPoolExecutor $ Worker.runTask(ThreadPoolExecutor.java:895) 在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:918) 在java.lang.Thread.run(Thread.java:662)

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'repositoryMembershipIndexService' defined in file [/home/rupanjan/Installations/apache-tomcat-7.0.39/webapps/pegonwheels-server/WEB-INF/classes/net/pegonwheels/spring/datasolr/domain/service/RepositoryMembershipIndexService.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [net.pegonwheels.spring.datasolr.domain.service.RepositoryMembershipIndexService]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: [Assertion failed] - this argument is required; it must not be null at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:306) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1120) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:662)

推荐答案

在代码中您拥有

private MembershipDocumentRepository repository = new SolrRepositoryFactory(this.solrMembershipTemplate)
       .getRepository(MembershipDocumentRepository.class);

,但是不能在没有CustomMembershipDocumentRepository的自定义实现的情况下构建您的MembershipDocumentRepository.

but your MembershipDocumentRepository can not be build with out custom implemention of CustomMembershipDocumentRepository.

如果实现了它,请检查名称.它必须与MembershipDocumentRepository在同一程序包中,并命名为MembershipDocumentRepositoryImpl(这是它的默认命名.

if you implemented it check the name.it must be in the same package as MembershipDocumentRepository and named MembershipDocumentRepositoryImpl ( this is the default naming for it.

这篇关于具有Solr 4.1多核的Spring Data Solr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 06:58