maven依賴指定版本範圍或者最新版本

在maven中我們經常像下面這樣引用一個依賴:

<dependency>
  <groupId>wonderful-inc</groupId>
  <artifactId>dream-library</artifactId>
  <version>1.2.3</version>
</dependency>

我們指定了固定的版本1.2.3,如果我們想每次都引用最新版本,是否可以呢?答案是可以的,在pom文件的定義中,可以使用版本的一個範圍,版本範圍的寫法說明如下:

  • (,1.0] x <= 1.0
  • 1.0 "Soft" requirement on 1.0 (just a recommendation - helps select the correct version if it matches all ranges)
  • [1.0] Hard requirement on 1.0
  • [1.2,1.3] 1.2 <= x <= 1.3
  • [1.0,2.0) 1.0 <= x < 2.0
  • [1.5,) x >= 1.5
  • (,1.0],[1.2,) x <= 1.0 or x >= 1.2. Multiple sets are comma-separated
  • (,1.1),(1.1,) This excludes 1.1 if it is known not to work in combination with this library

轉自:http://outofmemory.cn/code-snippet/12469/maven-specify-version-range

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章