2015-05-05 116 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依賴項。