Maven 手動添加 JAR 包到本地倉庫

Maven手動添加Jar到本地倉庫 (前提已有maven環境):

1.登錄 Maven中央倉庫搜索需要的Jar包(推薦maven鏡像倉庫);
http://mvnrepository.com/artifact/javax.xml/jaxb-impl/2.1
http://maven.oschina.net/content/groups/public/
http://mvnrepository.com/
http://repository.sonatype.org/content/groups/public/

2.記錄下Jar包的groupId,artifactId,version信息,並下載。

<!--例如的Jar如:spring-context-4.0.0.RELEASE.jar 注:將代碼添加至項目pom.xml-->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>4.0.0.RELEASE</version>
</dependency>

3.cmd控制檯運行以下命令,運行我的jar包路徑爲:D:\libs\jar\spring-context-4.0.0.RELEASE.jar。

mvn install:install-file -Dfile=D:\libs\jar\spring-context-4.0.0.RELEASE.jar -DgroupId=org.springframework -DartifactId=spring-context -Dversion=4.0.0.RELEASE -Dpackaging=jar

命令格式爲:
mvn install:install-file
-Dfile=jar包存放的位置
-DgroupId=Jar包的groupId
-DartifactId=Jar包的artifactId
-Dversion=Jar包的version
-Dpackaging=jar

注:自己寫了段生成mvn命令的java代碼,有興趣可以看下。
http://download.csdn.net/detail/n0_no/9624580

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章