最近我一直在研究一些前一段時間開發的項目的一些改進,這就是我發現的。很多pom文件中的依賴關係都沒有指定版本,但它們已解決。該項目由1個根模塊和2個子模塊組成。使用聚合器模式,這意味着根本沒有dependencyManagement部分。較高級的項目只需要彙總兩個模塊,這就是它的全部功能。子項目不會將其稱爲父項。他們有不同的父母。我無法理解的是,子項目本身和它們的父項(事實上它也沒有依賴項管理)都沒有指定某些依賴項的版本。例如:沒有版本的maven dependency
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>imap</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
有人可以幫我弄清楚這一點嗎?似乎maven處理一些默認策略的版本控制。
您能顯示'mvn -version'輸出嗎? –
沒有定義工件的版本,maven工作是不可能的。它們應該在子模塊或父代中的'dependencyManagement'標籤中的某處定義。請檢查您的pom層次結構。使用mvn help:effective-pom – Ozgen
您是否已通過'mvn help:effective-pom -Doutput = result.xml'進行檢查,並檢查是否沒有dependencyManagement。 – khmarbaise