一、将jar添加到本地仓库的做法:
以下面pom.xml依赖的jar包为例:
实际项目中pom.xml依赖写法:
[html] view plain copy
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context-support</artifactId>
- <version>3.1.0.RELEASE</version>
- </dependency>
Maven 安装 JAR 包的命令是:
[html] view plain copy
- mvn install:install-file
- -Dfile=jar包的位置
- -DgroupId=上面的groupId
- -DartifactId=上面的artifactId
- -Dversion=上面的version
- -Dpackaging=jar
例如我的这个spring-context-support-3.1.0.RELEASE.jar 文件放在了"D:\mvn\"中
则命令为:
mvn install:install-file
-Dfile=D:\mvn\spring-context-support-3.1.0.RELEASE.jar
-DgroupId=org.springframework
-DartifactId=spring-context-support
-Dversion=3.1.0.RELEASE
-Dpackaging=jar
注意:任何路径和名称不要有中文和空格,以防出现莫名其妙的错误。
二、上传Jar到远程marven仓库
命令:
[html] view plain copy
- mvn deploy:deploy-file -DgroupId=org.apache.thrift -DartifactId=libthrift -Dversion=1.12 -Dpackaging=jar -Dfile=D:\thrift-0.9.2.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可以看到