Maven依赖jar的自动升级配置

4 篇文章 0 订阅

当通过Maven创建一个组件项目中,即一个Maven工程通过多个工程组合起来。而每个工程形成一个jar包。一个总的工程需要依赖这些jar。如下面的配置:

我的site工程中包括

	<modules>
		<module>exambase</module>
		<module>unitpoint</module>
		<module>userrole</module>
		<module>resourcefile</module>
		<module>webexam</module>
		<module>base</module>
		<module>dimension</module>
		<module>exam_english</module>
		<module>filemanager</module>
		
	</modules>
其中”base“、”dimension","filemanager"三个工程为基础工程不需要依赖其他工程。而"userrole"工程需要依赖“base”工程,“unitpoint”工程需要依赖“userrole”,"filemanager","base"工程,"resourceFile"需要依赖“unitpoint”,"filemanager"工程,“exambase"需要依赖”filemanager“,"userrole","unitpoint"工程,"exam-english"需要依赖"exambase"工程,而”webexam“则需要依赖其他所有的工程。

当开发,如果我将Base工程的版本进行更新,则需要将所有相关联的pom.xml文件进行修改,以采用最新的版本。

因此我们可以采用maven的(dependencyManagement)功能进行最新版本的管理。

首先我们定义版本的升级规则;如我的版本为(0.0.1-SNAPSHOT).而第做一次修改版本号+1。

这个我的配置就是

<properties>
	<exam-version>[0.0.1-SNAPSHOT,]</exam-version>
</properties>

这个配置中的中括号逗号是必须的。

然后加入下面的配置。

<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>com.sdzn</groupId>
				<artifactId>exam-base</artifactId>
				<version>${exam-version}</version>
			</dependency>
			<dependency>
				<groupId>com.sdzn</groupId>
				<artifactId>exam-dimension</artifactId>
				<version>${exam-version}</version>
			</dependency>
			<dependency>
				<groupId>com.sdzn</groupId>
				<artifactId>exam-filemanager</artifactId>
				<version>${exam-version}</version>
			</dependency>
			<dependency>
				<groupId>com.sdzn</groupId>
				<artifactId>exam-userrole</artifactId>
				<version>${exam-version}</version>
			</dependency>
			<dependency>
				<groupId>com.sdzn</groupId>
				<artifactId>exam-unitpoint</artifactId>
				<version>${exam-version}</version>
			</dependency>
			<dependency>
				<groupId>com.sdzn</groupId>
				<artifactId>exam-resourcefile</artifactId>
				<version>${exam-version}</version>
			</dependency>
			<dependency>
				<groupId>com.sdzn</groupId>
				<artifactId>exam-exambase</artifactId>
				<version>${exam-version}</version>
			</dependency>
			<dependency>
				<groupId>com.sdzn</groupId>
				<artifactId>exam_english</artifactId>
				<version>${exam-version}</version>
			</dependency>
		</dependencies>
	</dependencyManagement>
这样只需要在有相关依赖的Pom.xml文件中加入下面的配置就可以了

	<dependencies>
		<dependency>
			<groupId>com.sdzn</groupId>
			<artifactId>exam-dimension</artifactId>
		</dependency>
		<dependency>
			<groupId>com.sdzn</groupId>
			<artifactId>exam-unitpoint</artifactId>
		</dependency>
	</dependencies>
由于版本我们以上通过 dependencyManagement进行管理。因此在这里只需要写上需要依赖的工程即可。



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值