在 Maven 中使用配置文件

发布于 2025-01-04 21:30:36 字数 1082 浏览 3 评论 0原文

我已将以下配置文件添加到我的 pom.xml 中:

<profiles>
    <profile>
        <id>nexus</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <distributionManagement>
            <repository>
                <id>nexusid1</id>
                   <url>http://</url>
            </repository>
            <snapshotRepository>
                <id>nexusid2</id>
                 <url>http://</url>
            </snapshotRepository>
        </distributionManagement>
    </profile>
</profiles>

我已添加到 settings.xml 中:

    <server>
<id>nexusid1</id>
<username>username</username>
<password>passwword</password>
    </server>

要将项目添加到 Nexus 存储库,我使用 mvn deploy

在这种情况下我需要使用配置文件吗? 如果我想部署到 nexusid2,这是否意味着我需要向 settings.xml 添加一个新的服务器条目,即使 nexusid1 和的用户名/密码是这样的? nexusid2 相同吗?

I have added below profile to my pom.xml :

<profiles>
    <profile>
        <id>nexus</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <distributionManagement>
            <repository>
                <id>nexusid1</id>
                   <url>http://</url>
            </repository>
            <snapshotRepository>
                <id>nexusid2</id>
                 <url>http://</url>
            </snapshotRepository>
        </distributionManagement>
    </profile>
</profiles>

I have added to settings.xml :

    <server>
<id>nexusid1</id>
<username>username</username>
<password>passwword</password>
    </server>

To add the project to the Nexus repo I use mvn deploy

Do I need to use a profile in this case ?
If I want to deploy to nexusid2 does this mean I need to add a new server entry to settings.xml even if the username/password for nexusid1 & nexusid2 are the same ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

为你鎻心 2025-01-11 21:30:36

根据 此页面,有一个 < mvn:deploy 的 code>-DaltDeploymentRepository 参数。但恕我直言,配置文件将是这里更优雅的解决方案,因为您不需要记住服务器 ID,而是记住配置文件名称。
是的,您需要将新服务器添加到 settings.xml,即使用户名和密码相同。

另外请注意:服务器管理的密码加密

According to this page, there is a -DaltDeploymentRepository argument for mvn:deploy. But imho, profiles would be the more elegant solution here, cause you don't need to remember the server id but the profile name.
And yes, you need to add a new server to the settings.xml, even if username and password are equal.

Note besides: Password encryption for server management

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文