0
    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);
        }
    }

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/classes/net 中定义的名称为“repositoryMembershipIndexService”的 bean 创建错误/pegonwheels/spring/datasolr/domain/service/RepositoryMembershipIndexService.class]:bean 的实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 bean 类 [net.pegonwheels.spring.datasolr.domain.service.RepositoryMembershipIndexService]:构造函数抛出异常;嵌套异常是 java.lang.IllegalArgumentException: [Assertion failed] - 此参数是必需的;在 org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:

4

1 回答 1

0

在你有的代码中

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

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

如果您实现了它,请检查名称。它必须MembershipDocumentRepository与命名在同一个包中MembershipDocumentRepositoryImpl(这是它的默认命名。

于 2015-02-02T11:39:43.760 回答