Trying to implement Spring-Data-Solr with Solr 4.1 multicores,
在服务器启动时遇到以下异常,我猜它希望某处有一个默认构造函数。那么,spring-data-solr是否存在solr muticores实现的限制,这是我的实现,
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);
}
}
<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:创建文件中定义名为'repositoryMembershipIndexService'的bean时出错[/home/rupanjan/Installations/apache-tomcat-7.0.39/webapps/pegonwheels-server/WEB-INF/ classes / net / pegonwheels / spring / datasolr / domain / service / RepositoryMembershipIndexService.class]:bean的实例化失败;嵌套异常是org.springframework.beans.BeanInstantiationException:无法实例化bean类[net.pegonwheels.spring.datasolr.domain.service.RepositoryMembershipIndexService]:构造函数抛出异常;嵌套异常是java.lang.IllegalArgumentException:[断言失败] - 这个参数是必需的;它不能为空 at 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) at 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) at 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) at 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) at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:439) at java.util.concurrent.FutureTask $ Sync.innerRun(FutureTask.java:303) 在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) 在java.lang.Thread.run(Thread.java:662)
答案 0 :(得分:0)
有
private MembershipDocumentRepository repository = new SolrRepositoryFactory(this.solrMembershipTemplate)
.getRepository(MembershipDocumentRepository.class);
但是您的MembershipDocumentRepository
无法使用CustomMembershipDocumentRepository
的自定义实现进行构建。
如果你实现了它,请检查name.it必须与MembershipDocumentRepository
在同一个包中并命名为MembershipDocumentRepositoryImpl
(这是它的默认命名。