Maven概述

依赖管理

依赖调节

  当多个手动创建的版本同时出现时,哪个依赖版本将会被使用。 

  (如果两个依赖版本在依赖树里的深度是一样的时候,第一个被声明的依赖将会被使用)。

依赖管理

  可以直接指定手动创建的某个版本供使用。

 依赖范围

  包含在构建过程每个阶段的依赖;

  compile :相关依赖是只在项目的类路径下有效。(默认取值) 

依赖排除

  任何可传递的依赖都可以通过 "exclusion" 元素被排除在外。

  (举例说明,A 依赖 B, B 依赖 C,因此 A 可以标记 C 为 "被排除的”)

 依赖可选

  任何可传递的依赖可以被标记为可选的,通过使用 "optional" 元素。

  (例如:A 依赖 B, B 依赖 C。因此,B 可以标记 C 为可选的, 这样 A 就可以不再使用 C)

Maven生命周期

clean

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building javasedemo 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ javasedemo ---
[INFO] Deleting /Users/an/IdeaProjects/javasedemo/target						删除目标目录下的内容
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.253 s
[INFO] Finished at: 2023-10-13T16:50:59+08:00
[INFO] Final Memory: 9M/309M
[INFO] ------------------------------------------------------------------------


compile

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building javasedemo 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ javasedemo ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ javasedemo ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 2 source files to /Users/an/IdeaProjects/javasedemo/target/classes				编译目标目录下的内容
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.164 s
[INFO] Finished at: 2023-10-13T16:51:52+08:00
[INFO] Final Memory: 15M/299M
[INFO] ------------------------------------------------------------------------

package

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building javasedemo 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ javasedemo ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ javasedemo ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ javasedemo ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/an/IdeaProjects/javasedemo/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ javasedemo ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ javasedemo ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ javasedemo ---
[INFO] Building jar: /Users/an/IdeaProjects/javasedemo/target/javasedemo-1.0-SNAPSHOT.jar		将目录下的内容打包
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.977 s
[INFO] Finished at: 2023-10-13T16:53:09+08:00
[INFO] Final Memory: 10M/245M
[INFO] ------------------------------------------------------------------------


install

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building javasedemo 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ javasedemo ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ javasedemo ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ javasedemo ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/an/IdeaProjects/javasedemo/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ javasedemo ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ javasedemo ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ javasedemo ---
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ javasedemo ---
[INFO] Installing /Users/an/IdeaProjects/javasedemo/target/javasedemo-1.0-SNAPSHOT.jar to /Users/an/.m2/repository/com/an/javasedemo/1.0-SNAPSHOT/javasedemo-1.0-SNAPSHOT.jar    
[INFO] Installing /Users/an/IdeaProjects/javasedemo/pom.xml to /Users/an/.m2/repository/com/an/javasedemo/1.0-SNAPSHOT/javasedemo-1.0-SNAPSHOT.pom  将目标包安装到本地仓库
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.017 s
[INFO] Finished at: 2023-10-13T16:54:28+08:00
[INFO] Final Memory: 12M/309M
[INFO] ------------------------------------------------------------------------


deploy

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building javasedemo 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ javasedemo ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ javasedemo ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 2 source files to /Users/an/IdeaProjects/javasedemo/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ javasedemo ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/an/IdeaProjects/javasedemo/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ javasedemo ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ javasedemo ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ javasedemo ---
[INFO] Building jar: /Users/an/IdeaProjects/javasedemo/target/javasedemo-1.0-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ javasedemo ---
[INFO] Installing /Users/an/IdeaProjects/javasedemo/target/javasedemo-1.0-SNAPSHOT.jar to /Users/an/.m2/repository/com/an/javasedemo/1.0-SNAPSHOT/javasedemo-1.0-SNAPSHOT.jar
[INFO] Installing /Users/an/IdeaProjects/javasedemo/pom.xml to /Users/an/.m2/repository/com/an/javasedemo/1.0-SNAPSHOT/javasedemo-1.0-SNAPSHOT.pom
[INFO] 
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ javasedemo ---
[INFO] ------------------------------------------------------------------------
    
          Uploading:http://...
    

  

  deploy 会将compile、test、package、install、deploy都执行

  

posted on 2023-10-13 17:08  anpeiyong  阅读(10)  评论(0)    收藏  举报

导航