如何在XML中编写基于注释的这部分配置?
@Bean
public EventRepository eventRepository() throws Exception {
return new SolrRepositoryFactory(eventTemplate())
.getRepository(EventRepository.class, new EventRepositoryImpl(eventTemplate()));
}
此配置的完整代码:
@Configuration
public class SolrContext {
@Bean
public SolrServerFactory solrServerFactory() {
return new MulticoreSolrServerFactory(new HttpSolrServer("solr.host"));
}
@Bean
public SolrTemplate eventTemplate() throws Exception {
SolrTemplate solrTemplate = new SolrTemplate(solrServerFactory());
solrTemplate.setSolrCore("events");
return solrTemplate;
}
@Bean
public EventRepository eventRepository() throws Exception {
return new SolrRepositoryFactory(eventTemplate())
.getRepository(EventRepository.class, new EventRepositoryImpl(eventTemplate()));
}
}
我从that回答中得到了这个例子。