Maven概述

依赖管理

依赖调节

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

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

依赖管理

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

 依赖范围

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

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

依赖排除

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

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

 依赖可选

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

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

Maven生命周期

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
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   anpeiyong  阅读(5)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示