I have written a Spring Boot console application (version 2.2.4. Spring-data-solr version 4.1.4) using CommandLineRunner interface. I have wired in a service that starts up a SolrTemplate connect. I use this to run a few queries against a Solr Index and then want to shut down the application.
When I debug the application I can step through the entire app, but when the app leaves main(), then it hangs. I assume that SolrTemplate is waiting for another query. Is there a way to shutdown SolrTemplate?
@Configuration
@EnableSolrRepositories(basePackages = { "org.ihc.hdd.serviceExample.facet.repository" })
public class SolrConfig {
@Value("${spring.data.solr.zk-host}")
private String zkHost;
@Bean
public SolrTemplate solrTemplate() throws Exception {
String[] zkHosts = this.zkHost.split(",");
CloudSolrClient cloudSolrClient = new CloudSolrClient.Builder(Arrays.asList(zkHosts), Optional.empty()).build();
return new SolrTemplate(cloudSolrClient);
}
}