我有一个 SolR 3.6 的测试环境,我正在尝试将其迁移到 4.0,但我收到以下错误。
主要源码如下:
public class SolrConfigTest extends AbstractSolrTestCase {
String container = "mycore";
@Override
public String getSolrHome() {
return System.getProperty("user.dir") + "/resources/";
}
@Override
public String getSchemaFile() {
return getSolrHome() + container + "/conf/schema.xml";
}
@Override
public String getSolrConfigFile() {
return getSolrHome() + container + "/conf/solrconfig.xml";
}
@Before
@Override
public void setUp() throws Exception {
super.setUp();
CoreContainer.Initializer initializer = new CoreContainer.Initializer();
coreContainer = initializer.initialize();
server = new EmbeddedSolrServer(coreContainer, "mycore");
}
}
solr 文件夹结构:
+solr
+mycore
+conf
+data
+lib
solr.xml 配置文件:
<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="false">
<cores adminPath="/admin/cores" defaultCoreName="mycore" host="${host:}" hostPort="${jetty.port:}" hostContext="${hostContext:}" zkClientTimeout="${zkClientTimeout:15000}">
<core name="mycore" instanceDir="mycore" />
</cores>
</solr>
但是,当我执行此代码时,出现以下错误:
[java] 16-dic-2012 0:43:15 SolrConfig <init> [java] 16-dic-2012 0:43:15 org.apache.solr.util.AbstractSolrTestCase setUp [java] INFO: ####SETUP_START <unknown> [java] 16-dic-2012 0:43:15 org.apache.solr.core.SolrResourceLoader <init> [java] INFO: new SolrResourceLoader for directory: '/home/user/workspace/tech/SolrTest/resources//collection1/' [java] 16-dic-2012 0:43:16 org.apache.solr.core.SolrConfig initLibs [java] INFO: Adding specified lib dirs to ClassLoader [java] 16-dic-2012 0:43:16 org.apache.solr.core.SolrConfig <init> [java] INFO: Using Lucene MatchVersion: LUCENE_40 [java] 16-dic-2012 0:43:16 org.apache.solr.core.SolrConfig <init> [java] INFO: Loaded SolrConfig: /home/user/workspace/tech/SolrTest/resources/mycore/conf/solrconfig.xml [java] 16-dic-2012 0:43:16 org.apache.solr.schema.IndexSchema readSchema [java] INFO: Reading Solr Schema [java] 16-dic-2012 0:43:16 org.apache.solr.schema.IndexSchema readSchema [java] INFO: Schema name=mycore [java] 16-dic-2012 0:43:17 org.apache.solr.schema.IndexSchema readSchema [java] INFO: unique key field: ID [java] java.lang.RuntimeException: java.io.IOException: Can't find resource 'stopwords.txt' in classpath or
'/home/user/workspace/tech/SolrTest/resources//collection1/conf/', cwd=/home/user/workspace/tech/SolrTest [java] at org.apache.solr.schema.IndexSchema.(IndexSchema.爪哇:116)
似乎 SolR 找不到 solr.xml(但确实找到了 solrconfig.xml),这就是为什么尝试访问 collection1(我已经读过,如果 solr 没有找到 solr.xml,则将核心设置为 collection1) ,但 getSolrHome() 指向的是存储 solr.xml 的文件夹。
我究竟做错了什么?
亲切的问候