0

我有我在测试中使用的这个 spring 配置:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:solr="http://www.springframework.org/schema/data/solr"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/data/solr
    http://www.springframework.org/schema/data/solr/spring-solr-1.0.xsd">

  <solr:embedded-solr-server id="tgySolrServer" solrHome="target/test-classes" />
</beans> 

现在抛出这个异常

Caused by: java.lang.NoSuchMethodError: org.apache.solr.core.CoreContainer.<init>(Ljava/lang/String;Ljava/io/File;)V
    at org.springframework.data.solr.server.support.EmbeddedSolrServerFactory.createPathConfiguredSolrServer(EmbeddedSolrServerFactory.java:101)
    at org.springframework.data.solr.server.support.EmbeddedSolrServerFactory.initSolrServer(EmbeddedSolrServerFactory.java:77)
    at org.springframework.data.solr.server.support.EmbeddedSolrServerFactoryBean.afterPropertiesSet(EmbeddedSolrServerFactoryBean.java:36)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
    ... 40 more

我目前有 Solr 4.5.0 和 spring-data-solr 1.0.0-RELEASE。我应该怎么做才能在我的测试中使用嵌入式服务器?

4

1 回答 1

1

我现在开始工作了

我们需要将以下依赖项和存储库添加到pom.xml

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-solr</artifactId>
    <version>1.1.0.BUILD-SNAPSHOT</version>
</dependency>

<repositories>
    <repository>
        <id>spring-maven-snapshot</id>
        <url>http://repo.springsource.org/libs-snapshot</url>
    </repository>
</repositories>

而已 !!!

于 2014-02-06T09:40:45.457 回答