首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在spring starter data-solr中启用schemaCreationSupport

在spring starter data-solr中启用schemaCreationSupport
EN

Stack Overflow用户
提问于 2016-09-30 12:51:03
回答 1查看 895关注 0票数 0

我使用Spring starter Data - Solr,并希望使用Spring的分离支持,如文档中所述。

每当刷新应用程序上下文时,自动架构填充将检查域类型,并根据属性配置将新字段填充到索引中。这需要solr在Schemaless模式下运行。

然而,我无法做到这一点。据我所见,Spring不启用@EnableSolrRepositories注释中的schemaCreationSupport标志。所以我尝试了以下几点:

代码语言:javascript
复制
@SpringBootApplication
@EnableSolrRepositories(schemaCreationSupport = true)
public class MyApplication {
  @Bean
  public SolrOperations solrTemplate(SolrClient solr) {
    return new SolrTemplate(solr);
  }
}

但是在Wireshark中,当通过存储库保存新实体时,我看不到对Schema的任何调用。

这是为了工作,还是我错过了什么?我使用Solr 6.2.0和Spring 1.4.1。

EN

回答 1

Stack Overflow用户

发布于 2016-10-12 14:00:37

我也遇到过同样的问题。经过一些调试之后,我发现了模式创建(或更新)根本没有发生的根本原因:

通过使用@EnableSolrRepositories注释,Spring扩展将向上下文中添加一个工厂bean,从而创建存储库中使用的SolrTemplate。该模板初始化一个SolrPersistentEntitySchemaCreator应该执行创建/更新

代码语言:javascript
复制
public void afterPropertiesSet() {

  if (this.mappingContext == null) {
    this.mappingContext = new SimpleSolrMappingContext(
      new SolrPersistentEntitySchemaCreator(this.solrClientFactory)
       .enable(this.schemaCreationFeatures));
  }

  // ...
}

问题是,在工厂调用schemaCreationFeatures (启用创建者)标志之后,afterPropertiesSet()被设置为afterPropertiesSet(),因此创建者不可能完成它的工作。

我将在问题跟踪器中创建一个问题。现在不要看到任何解决办法,其他的方法是使用自定义的叉/构建spring-数据,或者扩展一组spring-类,并试图在使用之前通过使用(但怀疑这一点)来设置标志。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39791966

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档