maven的pom.xml有些依赖为什么可以不写版本号?

本文详细解释了在Maven项目中,如何通过spring-boot-starter-parent简化依赖版本管理。介绍了如何利用parent标签自动继承版本号,避免手动指定版本可能带来的冲突。
<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
			<optional>true</optional>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-log4j2</artifactId>
		</dependency>

		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<!--<scope>runtime</scope>-->
		</dependency>

类似上面这种配置为什么有些可以不写版本号,也不会报错?

因为添加了parent标签。。。

<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.1.1.RELEASE</version>
		<relativePath/>
	</parent>

spring-boot-starter-parenth会为我们提供常用jar包版本,其实不是不用指定,是人家为我们指定好了。

自己指定版本号也可以,会覆盖官方版本,自己用maven helper查看一下有没有冲突即可。

转载于:https://my.oschina.net/MinghanSui/blog/3010358

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值