maven的pom.xml的依赖,不写版本号
xxx_core.xml:<modules><module>xxx-elasticsearch</module>...</modules><packaging>pom</packaging><name>xxx-core</name><description>xxx project for S
·
xxx_core.xml:
<modules>
<module>xxx-elasticsearch</module>
...
</modules>
<packaging>pom</packaging>
<name>xxx-core</name>
<description>xxx project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.16.RELEASE</version>
</parent>
xxx_elasticsearch.xml:
<parent>
<artifactId>xxx-core</artifactId>
<groupId>com.xxx</groupId>
<version>1.0.0</version>
</parent>
...
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
...
</dependencies>
我们发现es的maven依赖没有加version标签,但是并没有报错且es在项目能正常使用,查看jar包es自动取了6.4.3版本:
怀疑是core.xml中的parent的原因。
网上查阅一番资料,猜想并没有错,添加“parent”标签里的内容后,“spring-boot-starter-parent”会为开发者提供常用jar的版本管理,所以我们不需要指定版本,使用人家提供好的就可以了。当然,指定也是可以的,这会覆盖官方默认的版本,不推荐。
更多推荐
已为社区贡献1条内容
所有评论(0)