2015-05-05 85 views
1

我正在尝试在Spring Boot应用程序中使用ElasticsearchIntegrationTest(http://www.elastic.co/guide/en/elasticsearch/reference/1.x/integration-tests.html)进行集成测试。ElasticsearchIntegrationTest Spring Boot

@ElasticsearchIntegrationTest.ClusterScope(scope =ElasticsearchIntegrationTest.Scope.SUITE) 
public class MyElasticsearchIntegrationTests extends ElasticsearchIntegrationTest 

当我运行这个测试,我收到以下错误:

java.lang.AssertionError: Version must be upgraded to [4.10.4] is still set to  [4.10.3] 
at org.elasticsearch.Version.<clinit>(Version.java:229) 
at org.elasticsearch.test.ElasticsearchTestCase.<clinit>(ElasticsearchTestCase.java:87) 
at java.lang.Class.forName0(Native Method) 
at java.lang.Class.forName(Class.java:348) 
at com.carrotsearch.randomizedtesting.RandomizedRunner$1.run(RandomizedRunner.java:553) 

我的依赖是在我的pom.xml定义是这样的:

<dependencies> 
    <dependency> 
     <groupId>org.elasticsearch</groupId> 
     <artifactId>elasticsearch</artifactId> 
     <version>1.5.1</version> 
     <type>test-jar</type> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.lucene</groupId> 
     <artifactId>lucene-test-framework</artifactId> 
     <version>4.10.4</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-data-elasticsearch</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-web</artifactId> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-test</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.data</groupId> 
     <artifactId>spring-data-elasticsearch</artifactId> 
     <version>1.3.0.BUILD-SNAPSHOT</version> 
    </dependency> 
    <dependency> 
     <groupId>com.google.guava</groupId> 
     <artifactId>guava</artifactId> 
     <version>18.0</version> 
    </dependency> 
</dependencies> 

当我运行mvn依存度:树

[INFO] Scanning for projects... 
[INFO]                  
[INFO] ------------------------------------------------------------------------ 
[INFO] Building demo 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-dependency-plugin:2.10:tree (default-cli) @ demo --- 
[INFO] com.sebpc:demo:jar:0.0.1-SNAPSHOT 
[INFO] +- org.elasticsearch:elasticsearch:test-jar:tests:1.5.1:test 
[INFO] | +- org.apache.lucene:lucene-core:jar:4.10.4:compile 
[INFO] | +- org.apache.lucene:lucene-analyzers-common:jar:4.10.4:compile 
[INFO] | +- org.apache.lucene:lucene-queries:jar:4.10.4:compile 
[INFO] | +- org.apache.lucene:lucene-memory:jar:4.10.4:compile 
[INFO] | +- org.apache.lucene:lucene-highlighter:jar:4.10.4:compile 
[INFO] | +- org.apache.lucene:lucene-queryparser:jar:4.10.4:compile 
[INFO] | +- org.apache.lucene:lucene-sandbox:jar:4.10.4:compile 
[INFO] | +- org.apache.lucene:lucene-suggest:jar:4.10.4:compile 
[INFO] | +- org.apache.lucene:lucene-misc:jar:4.10.4:compile 
[INFO] | +- org.apache.lucene:lucene-join:jar:4.10.4:compile 
[INFO] | +- org.apache.lucene:lucene-grouping:jar:4.10.4:compile 
[INFO] | +- org.apache.lucene:lucene-spatial:jar:4.10.4:compile 
[INFO] | | \- com.spatial4j:spatial4j:jar:0.4.1:compile 
[INFO] | +- org.antlr:antlr-runtime:jar:3.5:compile 
[INFO] | +- org.ow2.asm:asm:jar:4.1:compile 
[INFO] | \- org.ow2.asm:asm-commons:jar:4.1:compile 
[INFO] +- org.apache.lucene:lucene-test-framework:jar:4.10.4:compile 
[INFO] | +- org.apache.lucene:lucene-codecs:jar:4.10.4:compile 
[INFO] | +- com.carrotsearch.randomizedtesting:junit4-ant:jar:2.1.6:compile 
[INFO] | +- com.carrotsearch.randomizedtesting:randomizedtesting- runner:jar:2.1.6:compile 
[INFO] | +- junit:junit:jar:4.12:compile 
[INFO] | \- org.apache.ant:ant:jar:1.8.2:compile 
[INFO] +- org.springframework.boot:spring-boot-starter-data-elasticsearch:jar:1.3.0.BUILD-SNAPSHOT:compile 
[INFO] | \- org.springframework.boot:spring-boot-starter:jar:1.3.0.BUILD-SNAPSHOT:compile 
[INFO] |  +- org.springframework.boot:spring-boot:jar:1.3.0.BUILD-SNAPSHOT:compile 
[INFO] |  +- org.springframework.boot:spring-boot-autoconfigure:jar:1.3.0.BUILD-SNAPSHOT:compile 
[INFO] |  +- org.springframework.boot:spring-boot-starter-logging:jar:1.3.0.BUILD-SNAPSHOT:compile 
[INFO] |  | +- ch.qos.logback:logback-classic:jar:1.1.3:compile 
[INFO] |  | | \- ch.qos.logback:logback-core:jar:1.1.3:compile 
[INFO] |  | +- org.slf4j:jul-to-slf4j:jar:1.7.11:compile 
[INFO] |  | \- org.slf4j:log4j-over-slf4j:jar:1.7.11:compile 
[INFO] |  \- org.yaml:snakeyaml:jar:1.14:compile 
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:1.3.0.BUILD-SNAPSHOT:compile 
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.3.0.BUILD-SNAPSHOT:compile 
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.0.21:compile 
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.0.21:compile 
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-logging-juli:jar:8.0.21:compile 
[INFO] | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.0.21:compile 
[INFO] | +- org.springframework.boot:spring-boot-starter-validation:jar:1.3.0.BUILD-SNAPSHOT:compile 
[INFO] | | \- org.hibernate:hibernate-validator:jar:5.1.3.Final:compile 
[INFO] | |  +- javax.validation:validation-api:jar:1.1.0.Final:compile 
[INFO] | |  +- org.jboss.logging:jboss-logging:jar:3.1.3.GA:compile 
[INFO] | |  \- com.fasterxml:classmate:jar:1.0.0:compile 
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.5.1:compile 
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.5.1:compile 
[INFO] | +- org.springframework:spring-web:jar:4.2.0.BUILD-SNAPSHOT:compile 
[INFO] | | +- org.springframework:spring-aop:jar:4.2.0.BUILD-SNAPSHOT:compile 
[INFO] | | | \- aopalliance:aopalliance:jar:1.0:compile 
[INFO] | | \- org.springframework:spring-beans:jar:4.2.0.BUILD-SNAPSHOT:compile 
[INFO] | \- org.springframework:spring-webmvc:jar:4.2.0.BUILD-SNAPSHOT:compile 
[INFO] |  \- org.springframework:spring-expression:jar:4.2.0.BUILD-SNAPSHOT:compile 
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.3.0.BUILD-SNAPSHOT:test 
[INFO] | +- org.mockito:mockito-core:jar:1.10.19:test 
[INFO] | | \- org.objenesis:objenesis:jar:2.1:test 
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:test 
[INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:test 
[INFO] | +- org.springframework:spring-core:jar:4.2.0.BUILD-SNAPSHOT:compile 
[INFO] | \- org.springframework:spring-test:jar:4.2.0.BUILD-SNAPSHOT:test 
[INFO] +- org.springframework.data:spring-data-elasticsearch:jar:1.3.0.BUILD-SNAPSHOT:compile 
[INFO] | +- org.springframework:spring-context:jar:4.2.0.BUILD-SNAPSHOT:compile 
[INFO] | +- org.springframework:spring-tx:jar:4.2.0.BUILD-SNAPSHOT:compile 
[INFO] | +- org.springframework.data:spring-data-commons:jar:1.10.0.RELEASE:compile 
[INFO] | +- commons-lang:commons-lang:jar:2.6:compile 
[INFO] | +- commons-collections:commons-collections:jar:3.2.1:compile 
[INFO] | +- joda-time:joda-time:jar:2.7:compile 
[INFO] | +- org.elasticsearch:elasticsearch:jar:1.4.4:compile 
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.5.1:compile 
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.11:compile 
[INFO] | \- org.slf4j:jcl-over-slf4j:jar:1.7.11:compile 
[INFO] \- com.google.guava:guava:jar:18.0:compile 

它看起来像所有的lucene相关的库是4.10.4,而不是4.10.3,这就是为什么我有点困惑这个错误消息。

任何帮助,将不胜感激!

感谢

回答

0

,除非你想使用特定的版本,因为它会被弹簧数据elasticsearch自动添加你不应该定义elasticsearch假象依赖。

与最新的弹簧数据elasticsearch快照1.3.0.BUILD-SNAPSHOT你会得到弹性搜索1.5.2这是最新版本无论如何。

建议:从您的pom中删除elasticsearch依赖项,并使用来自spring数据elasticsearch的临时依赖项。

如果您仍然想要使用特定版本,请从spring数据elasticsearch中排除elasticsearch依赖项。