一般来讲,maven deploy时要部署到Nexus,需要在pom.xml 中添加如下类似的东东:
1 2 3 4 5 6 7 8 9 10 11 12 |
<distributionManagement> <repository> <id>releases</id> <name>Nexus Release Repository</name> <url>http://nexus.phpor.net/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>snapshots</id> <name>Nexus Snapshot Repository</name> <url>http://nexus.phpor.net/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement> |
如此的话,该pom.xml 就不便于分享,还有人喜欢deploy到自己的Nexus呢;
其实,还可以在mvn deploy 时通过参数的方式来指定,如:
1 |
mvn deploy -D altDeploymentRepository=snapshots::default::http://nexus.phpor.net/nexus/content/repositories/snapshots/ |
这样的话,不管snapshot还是release都会deploy到相同位置; 正确的姿势为分别设置snapshot和release的位置,如下:
1 2 |
mvn deploy -D altSnapshotDeploymentRepository=snapshots::default::http://nexus.phpor.net/nexus/content/repositories/snapshots/ -D altReleaseDeploymentRepository=releases::default::http://nexus.phpor.net/nexus/content/repositories/releases/ |
参考:https://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html