标签导航:

idea 中配置了向远程私有仓库部署 jar 包,但 jar 包同时出现在 releases 和 snapshots 仓库中

在 IDEA 中,通过设置 distributionManagement 节点来配置向远程私有仓库部署 JAR 包。但是,在某些情况下,可能会遇到 JAR 包同时出现在 Releases 和 Snapshots 仓库中的问题。

问题原因

根据给定的版本号,即 "1.0.0-SNAPSHOT",JAR 包应该仅部署到 Snapshots 仓库中。然而,由于 pom.xml 文件中 distributionManagement 节点的 repository 和 snapshotRepository 的 id 相同,因此 Maven 将根据 id 管理仓库,并通过 Snapshots 仓库的 id 找到了 Releases 仓库,导致 JAR 包同时被发布到这两个仓库中。

解决方法

为了解决此问题,需要将 repository 和 snapshotRepository 的 id 设置为不同。例如,将 id 分别设置为 "x-repo-release" 和 "x-repo-snapshots"。这样,Maven 就能正确区分这两个仓库,并且 JAR 包将仅被部署到 Snapshots 仓库中。