我在父元素下看到repository
标签,即distributionManagement
和repositories
。有什么区别?
<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
元素指定在部署时将 Artifact 部署到的位置。它只会在 mvn deploy
时出现,即部署时间,而不是在 mvn install
(即构建时间)期间出现。对吗?
repository
元素指定需要从何处获取依赖项。它只会在 mvn install
期间出现,而不是在 mvn deploy
期间出现。对吗?
最佳答案
你说得完全正确!
来自POM reference :
Where as the
repositories
element specifies in the POM the location and manner in which Maven may download remote artifacts for use by the current project,distributionManagement
specifies where (and how) this project will get to a remote repository when it is deployed. The repository elements will be used for snapshot distribution if the snapshotRepository is not defined.
- 在
distributionManagement
元素下声明的存储库将用于部署,即在运行mvn deploy
时。 repositories
元素将用于下载项目的依赖项。该命令不一定是mvn install
,而是任何需要 Maven 从存储库获取 Artifact 的命令。
关于maven - distributionManagement 与存储库下的存储库标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35317118/