maven是现在最流行的项目管理工具,在企业中使用的非常广泛。
在一个maven管理的项目中,一般会配置很多依赖、插件,如何检查这些依赖是否有最新的版本?
除了去这些框架的官方网站上看,maven也自带了检查最新版本的方法
就是使用version插件versions-maven-plugin
versions:display-dependency-updates scans a project's dependencies and produces a report of those dependencies which have newer versions available.
versions:display-plugin-updates scans a project's plugins and produces a report of those plugins which have newer versions available.
versions:display-property-updates scans a projectand produces a report of those properties which are used to control artifact versions and which properies have newer versions available.
比如说,有配置如下依赖:
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.3.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.4.RELEASE</version>
</dependency>
</dependencies>
这里配置的是4.3.4,当前最新的版本是4.3.6
执行mvn versions:display-dependency-updates 查看是否有新的依赖版本:
报告里面已经指出有新的版本依赖,最新的依赖是4.3.6
如果项目里面已经是最新的依赖,则结果如下:
提示没有新的版本。
检查插件的方法类似(mvn versions:display-plugin-updates),这里就不重复演示了。