一、将jar包上传至nexus私服
格式:mvn deploy:deploy-file-Durl=file://C:\m2-repo \
-DrepositoryId=some.id \
-Dfile=your-artifact-1.0.jar \
[-DpomFile=your-pom.xml]\
[-DgroupId=org.some.group] \
[-DartifactId=your-artifact] \
[-Dversion=1.0] \
[-Dpackaging=jar] \
[-Dclassifier=test] \
[-DgeneratePom=true] \
[-DgeneratePom.description="My Project Description"] \
[-DrepositoryLayout=legacy] \
[-DuniqueVersion=false]
二、以java_memcached_release.2.6.6.jar为例:
①单个jar上传:
命令:mvndeploy:deploy-file -Dfile=d:\java_memcached_release_2.6.6.jar -sD:\settings.xml-DgroupId=com.danga -DartifactId =java-memcached -Dversion=2.6.6 -Durl=http://192.168.1.70:8081/nexus/content/repositories/thirdparty/-DrepositoryId=thirdparty
②将javamemcached client的jar包和pom文件一起安装,解决java memcached client对其他jar包的依赖。(主要区别在于DpomFile 的pom文件)
命令:mvndeploy:deploy-file -Dfile=d:\java_memcached_release_2.6.6.jar -DpomFile=d:\pom.xml -sD:\settings.xml -DgroupId=com.danga-DartifactId =java-memcached -Dversion=2.6.6 -Durl=http://192.168.1.70:8081/nexus/content/repositories/thirdparty/-DrepositoryId=thirdparty
pom文件格式:
<?xmlversion="1.0" encoding="UTF-8"?>
<projectxsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/xsd/maven-4.0.0.xsd"xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.danga</groupId>
<artifactId>java-memcached</artifactId>
<version>2.6.6</version>
<!-- 配置部署的远程仓库 -->
<!--配置部署的远程仓库 -->
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>nexusdistribution releases repository</name>
<url>http://192.168.1.70:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>nexusdistribution snapshot repository</name>
<url>http://192.168.1.70:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>1.5.6</version>
</dependency>
</dependencies>
</project>
setting.xml文件添加一下配置:
<server>
<id>nexus-releases</id>
<username>wwd</username>
<password>wwd</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>wwd</username>
<password>wwd</password>
</server>
<server>
<id>thirdparty</id>
<username>wwd</username>
<password>wwd</password>
</server>
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://192.168.1.70:8081/nexus/content/groups/seGroup/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>central-repos</id>
<repositories>
<repository>
<id>central</id>
<name>Central</name>
<url>http://192.168.1.70:8081/nexus/content/repositories/central/</url>
<releases>
<enable>true</enable>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>central-repos</activeProfile>
</activeProfiles>