我有我在测试中使用的弹簧配置:
<?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。在测试中如何使用嵌入式服务器?
答案 0 :(得分: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>
就是这样!!!