我編輯過的IntelliJ IDEA 2016年使用搖籃依賴管理兩個項目:項目A和B項目搖籃依賴管理 - 傳遞依賴版本不正確
項目用於elasticsearch定義編譯範圍依賴爲:
compile 'org.elasticsearch:elasticsearch:2.3.1'
項目B宣稱項目A編譯範圍依賴,像這樣:
compile 'com.mycompany:elasticsearch-common:2.3.1'
我所期望的,在對的Intelli工具搖籃窗口ĴIDEA 2016年,項目B到看到:
...
com.mycompany:elasticsearch-common:2.3.1 (Compile)
org.elasticsearch:elasticsearch:2.3.1 (Compile)
...
相反,我看到:
...
com.mycompany:elasticsearch-common:2.3.1 (Compile)
org.elasticsearch:elasticsearch:1.5.2 (Compile)
...
項目B無其他依賴性取決於elasticsearch,所以它沒有被其它依賴聲明覆蓋。
事實上,在我們的項目承上啓下pom.xml中有這樣的:
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.3.1</version>
<scope>compile</scope>
</dependency>
那麼爲什麼報告的IntelliJ爲elasticsearch的傳遞版本爲1.5.2?
我已經試過什麼:
- 刪除B項目目錄內.idea和.gradle
- 的gradle刪除緩存
- 無效緩存和重新啓動在的IntelliJ
- 宣誓
- 喝大量茶
- 問朋友和同事
- 發送電子郵件奧普拉
- 恢復到的IntelliJ 15時,所有這一切都被罰款(現在不再是)
- 便便(與5),並希望奇蹟般地自我修復的時候,我回去
以上都沒有工作。
什麼工作是專門在項目B中指定elasticsearch:2.3.1
依賴項,但是這不否定傳遞性依賴關係的整個原因?
任何幫助表示讚賞。
更新1
正如意見建議的LanceJava,我跑gradle dependencies
看看發生了什麼事。
這表明它是專門降級它:
org.elasticsearch:elasticsearch:2.3.1 -> 1.5.2
當我跑的是依賴gradle這個dependencyInsight它想出了:
:dependencyInsight
com.mycompany:elasticsearch-common:2.3.1 (selected by rule)
\--- compile
org.elasticsearch:elasticsearch:1.5.2 (selected by rule)
org.elasticsearch:elasticsearch:2.3.1 -> 1.5.2
\--- com.mycompany:elasticsearch-common:2.3.1
\--- compile
任何人有爲什麼發生這種情況的任何想法?
更新2
這似乎有了答案:https://discuss.gradle.org/t/excluded-dependence-comes-back-when-spring-boot-plugin-is-applied/17945/2
看來,gradle這個春天啓動插件喜歡接管了一下,執行它自己的依賴版本(雖然我不是使用使用彈簧數據的彈簧啓動啓動器)。
我解決了這個問題,加入:
ext[elasticsearch.version] = '2.3.1'
我的build.gradle文件。
嘗試'gradle dependencies' fom命令行。它應該告訴你發生了什麼事。也許有一個自定義[ResolutionStrategy](https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html) –
@LanceJava謝謝!我做到了這一點,它看起來像它是專門降級它: org.elasticsearch:elasticsearch:2.3.1 - > 1.5.2 當我做了dependencyInsight它得到了: org.elasticsearch:elasticsearch:1.5.2(選擇通過規則) org.elasticsearch:elasticsearch:2.3.1 - > 1.5.2 \ --- com.mycompany:elasticsearch-common:2.3.1 \ --- runtime – ndtreviv
@LanceJava查看更新。 – ndtreviv