maven管理springboot项目可以不用写依赖的版本号
学习springboot的时候发现maven的依赖是不用写版本号的,依然可以正常跑起来,这是为什么呢?
这是因为添加“parent”标签里的内容后,“spring-boot-starter-parent”会为开发者提供常用jar的版本管理,所以我们不需要指定版本,使用人家提供好的就可以了。当然,指定也是可以的,这会覆盖官方默认的版本,不推荐。
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.0</version>
</dependency>
<!--下面两个没有版本号 使用springboot提供好的版本 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>