问题描述
我在父元素下看到 repository
标签,即 distributionManagement
和 repositories
.有什么区别?
I see repository
tag under parent element i.e distributionManagement
and repositories
. What's the difference ?
<distributionManagement>
<repository>
<id>...</id>
<name>...</name>
<url>...</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<id>...</id>
<name>...</name>
<layout>default</layout>
<url>...</url>
</repository>
</repositories>
我的理解 distributionManagement
元素下的 repository
元素指定了在部署时将在何处部署工件.它只会在 mvn deploy
即部署时间出现,而不是在 mvn install
即构建时间.对吗?
My understanding repository
element under distributionManagement
element specifies where it will deploy the artifacts at the time of deployment. It will come into picture only while mvn deploy
i.e deployment time not during mvn install
i.e build time. Right?
repository
元素指定需要从何处获取依赖项.它只会在 mvn install
时出现,不会在 mvn deploy
期间出现.对吗?
repository
element under repositories element specifies from where dependencies needs to be picked up. It will come into picture only while mvn install
not during mvn deploy
. Right?
推荐答案
你说得对!
来自 POM 参考:
repositories
元素在 POM 中指定了 Maven 可以下载远程工件以供当前项目使用的位置和方式,distributionManagement
指定在哪里(以及如何) 该项目在部署后将进入远程存储库.如果未定义 snapshotRepository,则存储库元素将用于快照分发.
- 在
distributionManagement
元素下声明的存储库将用于部署,即在运行mvn deploy
时. repositories
元素将用于下载项目的依赖项.该命令不一定是mvn install
,而是任何需要 Maven 从存储库中获取工件的命令.- Repositories declared under the
distributionManagement
element will be used for deployment, i.e. when runningmvn deploy
. - The
repositories
element will be used for downloading dependencies of the project. The command is not necessarilymvn install
but any command that requires Maven to fetch artifacts from a repository.
这篇关于distributionManagement 与存储库下的存储库标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!