Enable schemaCreationSupport in spring-boot-starter-data-solr

落爺英雄遲暮 提交于 2019-12-02 08:09:41

I've run into the same problem. After some debugging, I've found the root cause why the schema creation (or update) is not happening at all:

By using the @EnableSolrRepositories annotation, an Spring extension will add a factory-bean to the context that creates the SolrTemplate that is used in the repositories. This template initialises a SolrPersistentEntitySchemaCreator, which should do the creation/update.

public void afterPropertiesSet() {

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

  // ...
}

Problem is that the flag schemaCreationFeatures (which enables the creator) is set after the factory calls the afterPropertiesSet(), so it's impossible for the creator to do it's work.

I'll create an issue in the spring-data-solr issue tracker. Don't see any workaround right now, other either having a custom fork/build of spring-data or extend a bunch of spring-classes and trying to get the flag set before by using (but doubt of this can be done).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!