maven的坐标,仓库介绍及配置(三)

阅读更多

1.什么是maven仓库?

  1.1 仓库和构件

  仓库指的是在某个位置统一存储所有maven项目共享构件

  构件可以是一个插件 可以是一个jar包也可以是我们自己输出的构建(或者说对项目打的包)
  maven的坐标,仓库介绍及配置(三)_第1张图片

  1.2 仓库分类

  maven的坐标,仓库介绍及配置(三)_第2张图片

   1.3 仓库中寻找构件的过程?

   maven的坐标,仓库介绍及配置(三)_第3张图片

 

 

2.什么是maven坐标(依赖)?

  2.1 坐标(依赖)定义

   坐标是标识构件在仓库中的唯一位置。
   maven的坐标,仓库介绍及配置(三)_第4张图片

  2.2 如何添加坐标(依赖)?
   例如:添加一个spring-test.jar的依赖过程
   1).打开maven的中央仓库:http://search.maven.org/
   2).搜索仓库:
  http://search.maven.org/#artifactdetails%7Corg.springframework%7Cspring-test%7C3.2.16.RELEASE%7Cjar
maven的坐标,仓库介绍及配置(三)_第5张图片
    3).配置maven pom,添加一组依赖,拷贝上面坐标地址:


    
        org.springframework
        spring-test
        3.2.16.RELEASE
    

 

3.如何发布项目到仓库

     mvn install :发布到本地仓库

     mvn deploy : 发布到远程仓库

 

     对本地项目发布到本地仓库:(本地仓库地址:D:\mavenRepository3\com\sohu\train\maven-02\1.0-SNAPSHORT\maven-02-1.0-SNAPSHORT.jar)

  

E:\train\test\maven-02>mvn clean install
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.sohu.train:maven-02:jar:1.0-SNAPSHORT
[WARNING] 'dependencies.dependency.exclusions.exclusion.groupId' for junit:junit:jar is missing. @ line 38, column 16
[WARNING] 'dependencies.dependency.exclusions.exclusion.artifactId' for junit:junit:jar is missing. @ line 38, column 16
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-02 1.0-SNAPSHORT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-02 ---
[INFO] Deleting E:\train\test\maven-02\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-02 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\train\test\maven-02\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-02 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to E:\train\test\maven-02\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-02 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\train\test\maven-02\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven-02 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to E:\train\test\maven-02\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven-02 ---
[INFO] Surefire report directory: E:\train\test\maven-02\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.sohu.train.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.008 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-02 ---
[INFO] Building jar: E:\train\test\maven-02\target\maven-02-1.0-SNAPSHORT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ maven-02 ---
[INFO] Installing E:\train\test\maven-02\target\maven-02-1.0-SNAPSHORT.jar to D:\mavenRepository3\com\sohu\train\maven-02\1.0-SNAPSHORT\mave
n-02-1.0-SNAPSHORT.jar
提交到本地仓库
[INFO] Installing E:\train\test\maven-02\pom.xml to D:\mavenRepository3\com\sohu\train\maven-02\1.0-SNAPSHORT\maven-02-1.0-SNAPSHORT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.112 s
[INFO] Finished at: 2016-01-13T17:08:22+08:00
[INFO] Final Memory: 13M/179M
[INFO] ------------------------------------------------------------------------

 

   

 

所有文章:

   参考:项目管理和java文章列表

maven系列文章: 

  1).maven的安装及常用命令(一)

  2).maven的生命周期,插件介绍(二)

  3).maven的坐标,仓库介绍及配置(三)

  4).maven的pom介绍及配置(四)

  5).maven的依赖特性,冲突解决(五)

  6).maven的聚合模块和pom继承使用(六)

  7).maven的版本规范(七)

  • maven的坐标,仓库介绍及配置(三)_第6张图片
  • 大小: 11.6 KB
  • maven的坐标,仓库介绍及配置(三)_第7张图片
  • 大小: 24.5 KB
  • maven的坐标,仓库介绍及配置(三)_第8张图片
  • 大小: 14.6 KB
  • maven的坐标,仓库介绍及配置(三)_第9张图片
  • 大小: 11.8 KB
  • maven的坐标,仓库介绍及配置(三)_第10张图片
  • 大小: 67.7 KB
  • 查看图片附件

你可能感兴趣的:(maven的坐标,仓库介绍及配置(三))