0
基本上我复制粘贴从http://docs.spring.io/spring-data/solr/docs/1.0.x/reference/html/solr.repositories.html多核配置,然后调整了一下,但它不起作用,因为我需要将corename-SolrClient添加到ClientFactory。但是,我是否仅仅是创造了SolrCLient?我希望它能匹配我机器上服务器上运行的核心。这是Solr的配置类:Java Spring如何设置多核Solr配置
private static final String PROPERTY_NAME_SOLR_SERVER_URL = "solr.host";
@Resource
private Environment environment;
@Bean
public SolrClientFactory solrClientFactory() {
MulticoreSolrClientFactory factory = new MulticoreSolrClientFactory(
new HttpSolrClient(environment.getRequiredProperty(
PROPERTY_NAME_SOLR_SERVER_URL)));
return factory;
}
@Bean (name = "SolrTemplateMap")
public Map<Language, SolrTemplate> solrTemplateList(){
HashMap<Language, SolrTemplate> map = new HashMap<>();
for (Language l : Language.values()){
SolrTemplate template = new SolrTemplate (solrClientFactory());
template.setSolrCore(l.toString());
map.put(l, template);
}
return map;
}
我试图在工厂bean添加
for (Language l : Language.values()){
factory.addSolrClientForCore(new HttpSolrClient(url + "/solr/" + l.toString()), l.toString());
}
,但它并没有解决任何问题。 Language
是一个枚举。