我尝试在我的应用程序中配置Solr(具有多核支持),每当我尝试注册转换器时,我都会得到ConverterNotFoundException
。
我已经介入,可以看到正在执行的查询和正在返回的文档。只是没有找到转换器。
我按照官方文档here中的示例进行了操作。
希望有人能够详细说明发生的事情,因为很难找到示例,而且在使用multicoreSupport=true
时,文档并不过分清楚添加转换器。
@Configuration
@EnableSolrRepositories(
multicoreSupport = true,
basePackages = {"uk.co.foo.bar.repository"})
public class SolrConfig {
@Resource
private Environment environment;
@Bean
public SolrClient solrClient(HttpClient httpClient) {
String solrHost = environment.getRequiredProperty("solr.host");
return new HttpSolrClient(solrHost, httpClient);
}
@Bean
public HttpClient httpClient() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(HttpClientUtil.PROP_BASIC_AUTH_USER, "user");
params.set(HttpClientUtil.PROP_BASIC_AUTH_PASS, "pass");
return HttpClientUtil.createClient(params);
}
@Bean
public SolrConverter solrConverter(CustomConversions customConversions){
MappingSolrConverter mappingSolrConverter= new MappingSolrConverter(new SimpleSolrMappingContext());
mappingSolrConverter.setCustomConversions(customConversions);
return mappingSolrConverter;
}
@Bean
public CustomConversions customConversions(){
return new CustomConversions(Arrays.asList(new fooConverter(), new barConverter()));
}
@Bean
public SolrTemplate solrTemplate(SolrClient solrClient, SolrConverter solrConverter){
SolrTemplate solrTemplate = new SolrTemplate(solrClient);
solrTemplate.setSolrConverter(solrConverter);
return solrTemplate;
}
}