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
是一個枚舉。