2012-11-15 32 views
1

我無法測試EmbeddedSOlrServer,我碰到以下情況例外Solr4.0測試EmbeddedSolrServer日食

Exception in thread main java.lang.NoClassDEfFOundError:org/apache/lucene/codecs/PostingFormat at org.apache.solr.core.SolrResourceLoader.reloadLuceneSPI(SolrResourceLoader.java:179)

碼 -

System.setProperty("solr.solr.home", "c:/apps/solr4/example/solr");
CoreContainer.Initializer initializer = new CoreContainer.Initializer();
CoreContainer coreContainer = initializer.initialize();
EmbeddedSolrServer server = new EmbeddedSolrServer(coreContainer, "");

我相信我有在類路徑和solr.solr.home所有罐子設置也被更新。請指教

+0

是否有日誌的詳細信息?如果可以的話,很高興看到引發此異常的代碼,爲您提供更準確的建議 – stephanruhl

+0

System.setProperty(「solr.solr.home」,「c:/ apps/solr4/example/solr」) ; CoreContainer.Initializer initializer = new CoreContainer.Initializer(); CoreContainer coreContainer = initializer.initialize(); EmbeddedSolrServer server = new EmbeddedSolrServer(coreContainer,「」); – ynaik

+1

通過逐個添加lucene jar來實現它。 – ynaik

回答

0

我解決增加了Lucene核心依賴到測試範圍的問題:

<dependency> 
     <groupId>org.apache.lucene</groupId> 
     <artifactId>lucene-core</artifactId> 
     <version>4.3.0</version> 
     <scope>test</scope> 
    </dependency>