![](/img/trans.png)
[英]What will the version be when I don't specify it in the Maven's pom.xml?
[英]What will happen if I don't specify a version for a Maven dependency?
我在項目 maven 依賴項中看到過,如下所示,
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</dependency>
依賴項中沒有定義版本,所以如果我不提供版本名稱以及為什么像上面那樣給出會發生什么。
請有人解釋原因。
我不認為你可以在你的項目的普通依賴部分中做到這一點。 我知道這是允許的唯一情況是當您繼承帶有<dependencyManagement>
部分的父項目時,該部分用於協調一組項目中的依賴項版本。 然后您可以使用“速記”定義,而無需版本。 但它仍然有一個版本,它從父項目中定義的依賴項繼承。
在 pom 中還有一些其他地方你也可以刪除版本,但那些與包含依賴項(如插件/排除等)沒有直接關系。
我已經在我的 pom.xml 中放置了以下帶有版本的 maven 依賴項,並且它工作正常。 <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <executions>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.