前提:maven等環境配置Ok
目標:把中央倉庫沒有的,部門內部 自研開發的jar,推到私服或者本地服務器,給相關項目組使用!
因為一般工程模塊自己mvn install就會推到倉庫,但是別人給你個jar包咋整?有源碼 一般mvn install就會上本地倉庫,沒有源碼只有jar包
1.在需要推的jar的位置,執行以下命令(注意空格和中杠) :mvn install:install-file -Dfile=E:\test\daofree.jar -DgroupId=com.njjn -DartifactId=daofree -Dversion=1.0 -Dpackaging=jar
2.BUILD SUCCESS后去倉庫查看,已經生成了目標文件。可以發現倉庫里的jar包名稱也已經按照命令參數發生了變化。
--安裝第三方jar包到本地倉庫
----進入jar包所在目錄運行
mvn install:install-file -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.1.37 -Dfile=fastjson-1.1.37.jar -Dpackaging=jar
----打開cmd直接運行
mvn install:install-file -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.1.37 -Dpackaging=jar -Dfile=E:\test\安裝第三方jar包\fastjson-1.1.37.jar
--安裝第三方jar包到私服nexus
--在settings配置文件中添加登錄私服第三方登錄信息
<server>
<id>thirdparty</id>
<username>admin</username>
<password>admin123</password>
</server>
----進入jar包所在目錄運行
mvn deploy:deploy-file -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.1.37 -Dpackaging=jar -Dfile=fastjson-1.1.37.jar -Durl=http://localhost:8081/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty
----打開cmd直接運行
mvn deploy:deploy-file -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.1.37 -Dpackaging=jar -Dfile=E:\test\fastjson-1.1.37.jar -Durl=http://localhost:8081/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty