摘要
maven install 本地jar
命令格式
mvn install:install-file -DgroupId=<group_name> -DartifactId=<artifact_name> -Dversion=<version_no> -Dfile=<path_of_the_local_jar> -Dpackaging=jar -DgeneratePom=true
示例
mvn install:install-file -DgroupId=com.qrcode -DartifactId=qrcode -Dversion=1.0 -Dfile=e:/test/QRCode.jar -Dpackaging=jar -DgeneratePom=true
添加依賴
<dependency> <groupId>com.qrcode</groupId> <artifactId>qrcode</artifactId> <version>1.0</version> </dependency>
本地jar包上傳
1.使用命令行
mvn deploy:deploy-file -DgroupId=com.hjz -DartifactId=hujunzheng -Dversion=0.0.1 -Dpackaging=jar -Dfile=jar包絕對路徑 -Durl=http:xxx/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty
DgroupId和DartifactId構成了該jar包在pom.xml的坐標,項目就是依靠這兩個屬性定位。自己起名字也行。
Dfile表示需要上傳的jar包的絕對路徑。
Durl私服上倉庫的位置,打開nexus——>repositories菜單,可以看到該路徑。
DrepositoryId服務器的表示id,在nexus的configuration可以看到。
Dversion表示版本信息,怎樣得到一個jar包准確的版本呢?
解壓該包,會發現一個叫MANIFEST.MF的文件,這個文件就有描述該包的版本信息。
比如Manifest-Version: 1.0可以知道該包的版本了。