我试图创造新的使用核心solrj。 我需要它来为我的应用程序准备测试。 我觉得这个代码是不完整的或错误的,因为每一次我得到了一个错误“没有核心的候选人”。
package com.itsystems.talentapp.config;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
import org.apache.solr.client.solrj.request.CoreAdminRequest;
import org.apache.solr.client.solrj.response.CoreAdminResponse;
import org.apache.solr.core.CoreContainer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import java.io.IOException;
@Configuration
public class SolrConfig {
@Autowired
SolrClient solrClient;
@Bean
@Profile("test")
public EmbeddedSolrServer embeddedSolrServer() throws IOException, SolrServerException {
String folder = "src/main/resources/solr/";
String coreName = "candidates";
CoreAdminResponse e = new CoreAdminRequest().createCore(coreName, folder, solrClient);
CoreContainer container = new CoreContainer(folder);
container.load();
return new EmbeddedSolrServer(container, "candidates");
}
}
错误:
org.apache.solr.common.SolrException: No such core: candidates
版:
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-core</artifactId>
<version>6.6.1</version>
</dependency>