在 Maven 中使用配置文件
我已将以下配置文件添加到我的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 此页面,有一个 <
mvn:deploy
的 code>-DaltDeploymentRepository 参数。但恕我直言,配置文件将是这里更优雅的解决方案,因为您不需要记住服务器 ID,而是记住配置文件名称。是的,您需要将新服务器添加到 settings.xml,即使用户名和密码相同。
另外请注意:服务器管理的密码加密
According to this page, there is a
-DaltDeploymentRepository
argument formvn: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