maven package to private server

Core command: mvn deploy

Original text: http://www.cnblogs.com/bigshark/p/5137354.html

One, placement

Add the following configuration to the pom.xml file in the project to be uploaded

<distributionManagement>

<repository>

<id>release</id>

<name>Release Repository</name>

<url>http://ip/nexus/content/repositories/releases</url>

</repository>

<snapshotRepository>

<id>snapshot</id>

<name>Snapshot Repository</name>

<url>http://ip/nexus/content/repositories/snapshots</url>

</snapshotRepository>

</distributionManagement>

 

We can configure the global url address in settings.xml, and obtain it dynamically in pom.xml.

Add the following global configuration to the default-profile of settings.xml

<properties>

<ReleaseRepository>http://ip/nexus/content/repositories/releases</ReleaseRepository>

<SnapshotRepository>http://ip/nexus/content/repositories/snapshots</SnapshotRepository>

</properties>

pom.xml changed to

<distributionManagement>

<repository>

<id>release</id>

<name>Release Repository</name>

<url>${ReleaseRepository}</url>

</repository>

<snapshotRepository>

<id>snapshot</id>

<name>Snapshot Repository</name>

<url>${SnapshotRepository}</url>

</snapshotRepository>

</distributionManagement>

这样,pom.xml中就可以动态获取settings.xml中的地址

 

除此之外,还要在settings.xml中配置鉴权账号,否则上传将报401鉴权错误

<server>

<id>deployment</id>

<username>deployment</username>

<password>deployment账号的密码</password>

</server>

 

二、命令

mvn deploy:deploy-file -DgroupId=groupId -DartifactId=artifactId -Dversion=version -Dfile=本地jar包路径 -DrepositoryId=releases/snapshots -Durl=仓库地址

举例:上传jmxri-1.2.1.jar,本地存放在D盘

mvn deploy:deploy-file -DgroupId=com.sun.jmx –DartifactId=jmxri -Dversion=1.2.1 -Dfile=d:/jmxri-1.2.1.jar -DrepositoryId=releases -Durl=http://ip/nexus/content/repositories/releases

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327029016&siteId=291194637