File —— New —— Other … —— MavenProject
All Catalogs ——org.apache.maven.archetypes —— maven-archetype-quickstart
UploadRepository.java
packagecom.dcf.core.demo;
public classUploadRepository {
public voidupload() {
System.out.println("Thisis upload repository example. ");
}
}
在配置文件pom.xml 中增加以下内容:
<distributionManagement>
<repository>
<id>nexus-releasesid>
<name>NexusReleasesname>
<url>http://192.168.14.217:9091/nexus/content/repositories/releases/url>
repository>
<snapshotRepository>
<id>nexus-snapshotsid>
<name>NexusSnapshotsname>
<url>http://192.168.14.217:9091/nexus/content/repositories/snapshotsurl>
snapshotRepository>
distributionManagement>
在配置文件settings.xml中
命令:
mvn install:install-file
-DgroupId=com.dcf.core.demo
-DartifactId=upload-repository
-Dversion=0.0.1-SNAPSHOT
-Dpackaging=jar-Dfile=F:\MyEclipse\upload-repository\target\upload-repository-0.0.1-SNAPSHOT.jar
执行日志:
执行日志:
1)进入项目目录
cd /d F:\MyEclipse\upload-repository
mvn deploy
可选参数:
-Dmaven.test.skip=true
该参数同时控制maven-compiler-plugin和maven-surefire-plugin两个插件的行为,即跳过编译,又跳过测试。
执行日志:
附加:
上传命令亦可使用
mvn deploy:deploy-file
-Dfile=F:\MyEclipse\upload-repository\upload-repository-0.0.1-SNAPSHOT.jar-DgroupId=com.dcf.core.demo
-DartifactId=upload-repository
-Dversion=0.0.1-SNAPSHOT-Durl=http://192.168.14.217:9091/nexus/content/repositories/snapshots/
-Dpackaging=jar-DrepositoryId=nexus-snapshots
使用浏览器登录:
http://192.168.14.217:9091/nexus/#welcome
File —— New —— Other … —— MavenProject
All Catalogs ——org.apache.maven.archetypes —— maven-archetype-quickstart
DownloadRepository.java
packagecom.dcf.core.api;
importcom.dcf.core.demo.UploadRepository;
public classDownloadRepository {
public static voidmain(String[] args) {
UploadRepositoryrepository =newUploadRepository();
repository.upload();
}
}
在配置文件pom.xml 中
<dependency>
<groupId>com.dcf.core.demogroupId>
<artifactId>upload-repositoryartifactId>
<version>0.0.1-SNAPSHOTversion>
dependency>
代码包:
http://download.csdn.net/detail/wyw3142731/9589843