将Jar安装到本地仓库和Jar上传到私服
举例
1. 依赖如下:
- <dependency>
- <groupId>org.quartz-scheduler.internal</groupId>
- <artifactId>quartz-terracotta-bootstrap</artifactId>
- <version>2.2.2-SNAPSHOT</version>
- </dependency>
将Jar包安装到本地仓库命令:
- mvn install:install-file -Dfile=D:\quartz-terracotta-bootstrap-2.2.2-SNAPSHOT.jar -DgroupId=org.quartz-scheduler.internal -DartifactId=quartz-terracotta-bootstrap -Dversion=2.2.2-SNAPSHOT -Dpackaging=jar
-- DgroupId和DartifactId构成了该jar包在pom.xml的坐标, 对应依赖的DgroupId和DartifactId
-- Dfile表示需要上传的jar包的绝对路径
-- Dpackaging 为安装文件的种类
2. 上传Jar到私服
命令:
- mvn deploy:deploy-file -DgroupId=org.terracotta.toolkit -DartifactId=terracotta-toolkit-api-internal -Dversion=1.12 -Dpackaging=jar -Dfile=D:\terracotta-toolkit-api-internal-1.12.jar -Durl=http://ip:port/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty
-- DgroupId和DartifactId构成了该jar包在pom.xml的坐标, 对应依赖的DgroupId和DartifactId
-- Dfile表示需要上传的jar包的绝对路径
-- Durl私服上仓库的url精确地址(打开nexus左侧repositories菜单,可以看到该路径)
-- DrepositoryId服务器的表示id,在nexus的configuration可以看到
mvn install:install-file -Dfile=D:\test\com.exmyth.gprinter.jar -DgroupId=com.exmyth -DartifactId=gprinter -Dversion=1.0 -Dpackaging=jar
mvn install:install-file -DgroupId=com.exmyth -DartifactId=gprinter -Dversion=1.0 -Dfile=D:\test\com.exmyth.gprinter.jar -Dpackaging=jar -DgeneratePom=true -DlocalRepositoryPath=D:\test\mvn -DcreateChecksum=true
mvn deploy:deploy-file -DgroupId=com.exmyth -DartifactId=gprinter -Dversion=1.0 -Dpackaging=jar -Dfile=D:\test\com.exmyth.gprinter.jar -Durl=http://192.168.199.182:9091/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty
本地
D:\test\mvn>mvn install:install-file -Dfile=D:\test\com.exmyth.gprinter.jar -D groupId=com.exmyth -DartifactId=gprinter -Dversion=1.0 -Dpackaging=jar [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Stub Project (No POM) 1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom --- [INFO] Installing D:\test\com.exmyth.gprinter.jar to D:\repository\com\exmyth\gp rinter\1.0\gprinter-1.0.jar [INFO] Installing C:\Users\WPWL\AppData\Local\Temp\mvninstall8371599131162576038 .pom to D:\repository\com\exmyth\gprinter\1.0\gprinter-1.0.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.528 s [INFO] Finished at: 2016-07-21T13:57:47+08:00 [INFO] Final Memory: 7M/123M [INFO] ------------------------------------------------------------------------
私服
D:\test\mvn>mvn deploy:deploy-file -DgroupId=com.exmyth -DartifactId=gprinter -D version=1.0 -Dpackaging=jar -Dfile=D:\test\com.exmyth.gprinter.jar -Durl=http:// 192.168.199.182:9091/nexus/content/repositories/thirdparty/ -DrepositoryId=third party [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Stub Project (No POM) 1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-deploy-plugin:2.7:deploy-file (default-cli) @ standalone-pom -- - Uploading: http://192.168.199.182:9091/nexus/content/repositories/thirdparty/com /exmyth/gprinter/1.0/gprinter-1.0.jar Uploading: http://192.168.199.182:9091/nexus/content/repositories/thirdparty/com /exmyth/gprinter/1.0/gprinter-1.0.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.726 s [INFO] Finished at: 2016-07-21T14:14:35+08:00 [INFO] Final Memory: 8M/155M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7: deploy-file (default-cli) on project standalone-pom: Failed to deploy artifacts: Could not transfer artifact com.exmyth:gprinter:jar:1.0 from/to thirdparty (htt p://192.168.199.182:9091/nexus/content/repositories/thirdparty/): Failed to tran sfer file: http://192.168.199.182:9091/nexus/content/repositories/thirdparty/com /exmyth/gprinter/1.0/gprinter-1.0.jar. Return code is: 401, ReasonPhrase: Unauth orized. -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit ch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please rea d the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE xception D:\test\mvn>