配置Maven本地仓库

简介:

1、下载解压缩Maven到本地目录

   D:\apache-maven-3.3.9



2、配置Maven本地仓库

   打开D:\apache-maven-3.3.9\conf\settings.xml


   在第55行附近添加:

1
   < localRepository >d:\Library\maven-repo</ localRepository >

 

   在第213行附近添加:  

1
2
3
4
5
6
7
8
9
10
11
12
     < profile >
          < id >jdk-1.8</ id >
             < activation >
                       < activeByDefault >true</ activeByDefault >
                      < jdk >1.8</ jdk >
               </ activation >
              < properties >
                       < maven.compiler.source >1.8</ maven.compiler.source >
                   < maven.compiler.target >1.8</ maven.compiler.target >
                   < maven.compiler.compilerVersion >1.8</ maven.compiler.compilerVersion >
                 </ properties >
      </ profile >


3、添加一个自定义jar到本地仓库中

D:\apache-maven-3.3.9\bin>mvn install:install-file -Dfile=C:/Users/leizm/Desktop/ansj_seg-5.0.0-all-in-one.jar -DgroupId=org.ansj -DartifactId=ansj_seg -Dversio n=5.0.0 -Dpackaging=jar


那么在pom.xml中的依赖配置为:

1
2
3
4
5
< dependency >
     < groupId >org.ansj</ groupId >
     < artifactId >ansj_seg</ artifactId >
     < version >5.0.0</ version >
</ dependency >


执行命令如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
D:\apache-maven-3.3.9\bin>mvn  install : install - file  -Dfile=C: /Users/leizm/Desktop
/ansj_seg-5 .0.0-all- in -one.jar -DgroupId=org.ansj -DartifactId=ansj_seg -Dversio
n=5.0.0 -Dpackaging=jar
[INFO] Scanning  for  projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven- install -plugin:2.4: install - file  (default-cli) @ standalone-pom
---
[INFO] Installing C:\Users\leizm\Desktop\ansj_seg-5.0.0-all- in -one.jar to d:\Lib
rary\maven-repo\org\ansj\ansj_seg\5.0.0\ansj_seg-5.0.0.jar
[INFO] Installing C:\Users\leizm\AppData\Local\Temp\mvninstall158649410227741988
1.pom to d:\Library\maven-repo\org\ansj\ansj_seg\5.0.0\ansj_seg-5.0.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total  time : 0.793 s
[INFO] Finished at: 2016-07-04T17:15:43+08:00
[INFO] Final Memory: 8M /241M
[INFO] ------------------------------------------------------------------------
 
D:\apache-maven-3.3.9\bin>


4、给出一个实际的pom.xml文件

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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
< project  xmlns = "http://maven.apache.org/POM/4.0.0"  xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" >
     < modelVersion >4.0.0</ modelVersion >
     < groupId >com.lfw</ groupId >
     < artifactId >lfwsv</ artifactId >
     < packaging >war</ packaging >
     < version >1.0-SNAPSHOT</ version >
     < name >lfwsv Maven Webapp</ name >
     < url >http://maven.apache.org</ url >
     < dependencies >
         <!--框架-->
         < dependency >
             < groupId >asm</ groupId >
             < artifactId >asm</ artifactId >
             < version >3.3.1</ version >
         </ dependency >
         < dependency >
             < groupId >aopalliance</ groupId >
             < artifactId >aopalliance</ artifactId >
             < version >1.0</ version >
         </ dependency >
         < dependency >
             < groupId >org.aspectj</ groupId >
             < artifactId >aspectjrt</ artifactId >
             < version >1.8.4</ version >
         </ dependency >
         < dependency >
             < groupId >org.aspectj</ groupId >
             < artifactId >aspectjweaver</ artifactId >
             < version >1.7.3</ version >
         </ dependency >
         < dependency >
             < groupId >cglib</ groupId >
             < artifactId >cglib</ artifactId >
             < version >2.2.2</ version >
         </ dependency >
         < dependency >
             < groupId >commons-logging</ groupId >
             < artifactId >commons-logging</ artifactId >
             < version >1.1.3</ version >
         </ dependency >
         < dependency >
             < groupId >org.slf4j</ groupId >
             < artifactId >slf4j-api</ artifactId >
             < version >1.7.5</ version >
         </ dependency >
         < dependency >
             < groupId >org.slf4j</ groupId >
             < artifactId >slf4j-log4j12</ artifactId >
             < version >1.7.5</ version >
         </ dependency >
         < dependency >
             < groupId >log4j</ groupId >
             < artifactId >log4j</ artifactId >
             < version >1.2.17</ version >
         </ dependency >
         < dependency >
             < groupId >dom4j</ groupId >
             < artifactId >dom4j</ artifactId >
             < version >1.6.1</ version >
         </ dependency >
         < dependency >
             < groupId >xml-apis</ groupId >
             < artifactId >xml-apis</ artifactId >
             < version >1.0.b2</ version >
         </ dependency >
         < dependency >
             < groupId >commons-beanutils</ groupId >
             < artifactId >commons-beanutils</ artifactId >
             < version >1.8.3</ version >
         </ dependency >
         < dependency >
             < groupId >commons-cli</ groupId >
             < artifactId >commons-cli</ artifactId >
             < version >1.1</ version >
         </ dependency >
         < dependency >
             < groupId >commons-collections</ groupId >
             < artifactId >commons-collections</ artifactId >
             < version >3.2.1</ version >
         </ dependency >
         < dependency >
             < groupId >commons-codec</ groupId >
             < artifactId >commons-codec</ artifactId >
             < version >1.10</ version >
         </ dependency >
         < dependency >
             < groupId >commons-dbcp</ groupId >
             < artifactId >commons-dbcp</ artifactId >
             < version >1.4</ version >
         </ dependency >
         < dependency >
             < groupId >commons-fileupload</ groupId >
             < artifactId >commons-fileupload</ artifactId >
             < version >1.3.1</ version >
         </ dependency >
         < dependency >
             < groupId >commons-io</ groupId >
             < artifactId >commons-io</ artifactId >
             < version >2.4</ version >
         </ dependency >
         < dependency >
             < groupId >commons-lang</ groupId >
             < artifactId >commons-lang</ artifactId >
             < version >2.6</ version >
         </ dependency >
         < dependency >
             < groupId >commons-pool</ groupId >
             < artifactId >commons-pool</ artifactId >
             < version >1.6</ version >
         </ dependency >
         < dependency >
             < groupId >org.apache.commons</ groupId >
             < artifactId >commons-pool2</ artifactId >
             < version >2.3</ version >
         </ dependency >
 
         < dependency >
             < groupId >net.sf.ehcache</ groupId >
             < artifactId >ehcache-core</ artifactId >
             < version >2.5.0</ version >
         </ dependency >
         < dependency >
             < groupId >com.alibaba</ groupId >
             < artifactId >fastjson</ artifactId >
             < version >1.2.11</ version >
         </ dependency >
 
         <!-- alibaba连接池-->
         < dependency >
             < groupId >com.alibaba</ groupId >
             < artifactId >druid</ artifactId >
             < version >1.0.19</ version >
         </ dependency >
         <!--junit-->
         < dependency >
             < groupId >junit</ groupId >
             < artifactId >junit</ artifactId >
             < version >4.12</ version >
         </ dependency >
         < dependency >
             < groupId >org.hamcrest</ groupId >
             < artifactId >hamcrest-core</ artifactId >
             < version >1.3</ version >
         </ dependency >
 
         <!--jackson-->
         < dependency >
             < groupId >com.fasterxml.jackson.core</ groupId >
             < artifactId >jackson-annotations</ artifactId >
             < version >2.3.1</ version >
         </ dependency >
         < dependency >
             < groupId >com.fasterxml.jackson.core</ groupId >
             < artifactId >jackson-core</ artifactId >
             < version >2.3.1</ version >
         </ dependency >
         < dependency >
             < groupId >com.fasterxml.jackson.core</ groupId >
             < artifactId >jackson-databind</ artifactId >
             < version >2.3.1</ version >
         </ dependency >
         < dependency >
             < groupId >com.fasterxml.jackson.module</ groupId >
             < artifactId >jackson-module-jaxb-annotations</ artifactId >
             < version >2.3.1</ version >
         </ dependency >
         <!--mybatis-->
         < dependency >
             < groupId >org.mybatis</ groupId >
             < artifactId >mybatis</ artifactId >
             < version >3.2.8</ version >
         </ dependency >
         < dependency >
             < groupId >org.mybatis</ groupId >
             < artifactId >mybatis-spring</ artifactId >
             < version >1.3.0</ version >
         </ dependency >
         < dependency >
             < groupId >mysql</ groupId >
             < artifactId >mysql-connector-java</ artifactId >
             < version >5.1.38</ version >
         </ dependency >
 
         <!--spring-->
         < dependency >
             < groupId >org.springframework</ groupId >
             < artifactId >spring-aspects</ artifactId >
             < version >3.2.12.RELEASE</ version >
         </ dependency >
         < dependency >
             < groupId >org.springframework</ groupId >
             < artifactId >spring-aop</ artifactId >
             < version >3.2.12.RELEASE</ version >
         </ dependency >
         < dependency >
             < groupId >org.springframework</ groupId >
             < artifactId >spring-beans</ artifactId >
             < version >3.2.12.RELEASE</ version >
         </ dependency >
         < dependency >
             < groupId >org.springframework</ groupId >
             < artifactId >spring-context</ artifactId >
             < version >3.2.12.RELEASE</ version >
         </ dependency >
         < dependency >
             < groupId >org.springframework</ groupId >
             < artifactId >spring-context-support</ artifactId >
             < version >3.2.12.RELEASE</ version >
         </ dependency >
         < dependency >
             < groupId >org.springframework</ groupId >
             < artifactId >spring-core</ artifactId >
             < version >3.2.12.RELEASE</ version >
         </ dependency >
         < dependency >
             < groupId >org.springframework</ groupId >
             < artifactId >spring-expression</ artifactId >
             < version >3.2.12.RELEASE</ version >
         </ dependency >
         < dependency >
             < groupId >org.springframework</ groupId >
             < artifactId >spring-instrument</ artifactId >
             < version >3.2.12.RELEASE</ version >
         </ dependency >
         < dependency >
             < groupId >org.springframework</ groupId >
             < artifactId >spring-instrument-tomcat</ artifactId >
             < version >3.2.12.RELEASE</ version >
         </ dependency >
         < dependency >
             < groupId >org.springframework</ groupId >
             < artifactId >spring-jdbc</ artifactId >
             < version >3.2.12.RELEASE</ version >
         </ dependency >
         < dependency >
             < groupId >org.springframework</ groupId >
             < artifactId >spring-jms</ artifactId >
             < version >3.2.12.RELEASE</ version >
         </ dependency >
         < dependency >
             < groupId >org.springframework</ groupId >
             < artifactId >spring-oxm</ artifactId >
             < version >3.2.12.RELEASE</ version >
         </ dependency >
         < dependency >
             < groupId >org.springframework</ groupId >
             < artifactId >spring-test</ artifactId >
             < version >3.2.12.RELEASE</ version >
         </ dependency >
         < dependency >
             < groupId >org.springframework</ groupId >
             < artifactId >spring-tx</ artifactId >
             < version >3.2.12.RELEASE</ version >
         </ dependency >
         < dependency >
             < groupId >org.springframework</ groupId >
             < artifactId >spring-web</ artifactId >
             < version >3.2.12.RELEASE</ version >
         </ dependency >
         < dependency >
             < groupId >org.springframework</ groupId >
             < artifactId >spring-webmvc</ artifactId >
             < version >3.2.12.RELEASE</ version >
         </ dependency >
         < dependency >
             < groupId >org.springframework.data</ groupId >
             < artifactId >spring-data-redis</ artifactId >
             < version >1.4.2.RELEASE</ version >
         </ dependency >
 
         <!-- poi-->
         < dependency >
             < groupId >org.apache.poi</ groupId >
             < artifactId >poi</ artifactId >
             < version >3.11</ version >
         </ dependency >
         < dependency >
             < groupId >org.apache.poi</ groupId >
             < artifactId >poi-ooxml</ artifactId >
             < version >3.11</ version >
         </ dependency >
         < dependency >
             < groupId >org.apache.poi</ groupId >
             < artifactId >poi-ooxml-schemas</ artifactId >
             < version >3.11</ version >
         </ dependency >
         < dependency >
             < groupId >org.apache.xmlbeans</ groupId >
             < artifactId >xmlbeans</ artifactId >
             < version >2.6.0</ version >
         </ dependency >
 
         <!-- itext-->
         < dependency >
             < groupId >com.itextpdf</ groupId >
             < artifactId >itextpdf</ artifactId >
             < version >5.4.5</ version >
         </ dependency >
         < dependency >
             < groupId >com.itextpdf</ groupId >
             < artifactId >itext-asian</ artifactId >
             < version >5.2.0</ version >
         </ dependency >
 
         <!-- freemarker-->
         < dependency >
             < groupId >freemarker</ groupId >
             < artifactId >freemarker</ artifactId >
             < version >2.3.2</ version >
         </ dependency >
 
         <!-- httpclient-->
         < dependency >
             < groupId >org.apache.httpcomponents</ groupId >
             < artifactId >httpcore</ artifactId >
             < version >4.4.1</ version >
         </ dependency >
         < dependency >
             < groupId >org.apache.httpcomponents</ groupId >
             < artifactId >httpclient</ artifactId >
             < version >4.4.1</ version >
         </ dependency >
         < dependency >
             < groupId >org.apache.httpcomponents</ groupId >
             < artifactId >httpmime</ artifactId >
             < version >4.4.1</ version >
         </ dependency >
         < dependency >
             < groupId >org.apache.httpcomponents</ groupId >
             < artifactId >httpclient-cache</ artifactId >
             < version >4.4.1</ version >
         </ dependency >
 
         <!--工具包-->
         < dependency >
             < groupId >com.github.cage</ groupId >
             < artifactId >cage</ artifactId >
             < version >1.0</ version >
         </ dependency >
         < dependency >
             < groupId >net.coobird</ groupId >
             < artifactId >thumbnailator</ artifactId >
             < version >0.4.8</ version >
         </ dependency >
         < dependency >
             < groupId >com.h2database</ groupId >
             < artifactId >h2</ artifactId >
             < version >1.4.190</ version >
         </ dependency >
         < dependency >
             < groupId >redis.clients</ groupId >
             < artifactId >jedis</ artifactId >
             < version >2.6.2</ version >
         </ dependency >
         < dependency >
             < groupId >jstl</ groupId >
             < artifactId >jstl</ artifactId >
             < version >1.2</ version >
         </ dependency >
         < dependency >
             < groupId >org.apache.tomcat</ groupId >
             < artifactId >servlet-api</ artifactId >
             < version >3.0</ version >
         </ dependency >
         < dependency >
             < groupId >framework</ groupId >
             < artifactId >framework</ artifactId >
             < version >1.0</ version >
         </ dependency >
         < dependency >
             < groupId >org.ansj</ groupId >
             < artifactId >ansj_seg</ artifactId >
             < version >5.0.0</ version >
         </ dependency >
     </ dependencies >
 
     <!-- 发布路径-->
     <!--<distributionManagement>-->
     <!--&lt;!&ndash; 正式版发布路径&ndash;&gt;-->
     <!--<repository>-->
     <!--<id>nexus-releases</id>-->
     <!--<name>Nexus Release Repository</name>-->
     <!--<url>http://192.168.1.200:8081/nexus/content/repositories/releases/</url>-->
     <!--</repository>-->
     <!--&lt;!&ndash; 快照版发布路径&ndash;&gt;-->
     <!--<snapshotRepository>-->
     <!--<id>nexus-snapshots</id>-->
     <!--<name>Nexus Snapshot Repository</name>-->
     <!--<url>http://192.168.1.200:8081/nexus/content/repositories/snapshots/</url>-->
     <!--</snapshotRepository>-->
     <!--</distributionManagement>-->
 
     < properties >
         <!-- 文件拷贝时的编码 -->
         < project.build.sourceEncoding >UTF-8</ project.build.sourceEncoding >
         < project.reporting.outputEncoding >UTF-8</ project.reporting.outputEncoding >
         <!-- 编译时的编码 -->
         < maven.compiler.encoding >UTF-8</ maven.compiler.encoding >
     </ properties >
 
     < build >
         < finalName >lfwsv</ finalName >
 
         <!-- 声明不需要web.xml-->
         < plugins >
             < plugin >
                 < groupId >org.apache.maven.plugins</ groupId >
                 < artifactId >maven-compiler-plugin</ artifactId >
                 < configuration >
                     < source >1.8</ source >
                     < target >1.8</ target >
                     < encoding >utf-8</ encoding >
                 </ configuration >
             </ plugin >
             <!--<plugin>-->
             <!--<groupId>org.apache.maven.plugins</groupId>-->
             <!--<artifactId>maven-war-plugin</artifactId>-->
             <!--<configuration>-->
             <!--<failOnMissingWebXml>false</failOnMissingWebXml>-->
             <!--</configuration>-->
             <!--</plugin>-->
         </ plugins >
         <!-- 设置xml文件打包时保留-->
         < resources >
             < resource >
                 < directory >src/main/java</ directory >
                 < includes >
                     < include >**/*.xml</ include >
                 </ includes >
                 < filtering >true</ filtering >
             </ resource >
         </ resources >
     </ build >
</ project >




本文转自 leizhimin 51CTO博客,原文链接:http://blog.51cto.com/lavasoft/1795851,如需转载请自行联系原作者

相关文章
|
8月前
|
Java 应用服务中间件 Maven
在IntelliJ IDEA中如何配置使用Maven以创建Tomcat环境
所以,别担心这些工具看起来有些吓人,实际上这些都是为了帮助你更好的完成工作的工具,就像超市里的各种烹饪工具一样,尽管它们看起来可能很复杂,但只要你学会用,它们会为你烹饪出一道道美妙的食物。这就是学习新技能的乐趣,让我们一起享受这个过程,攀登知识的高峰!
568 27
|
8月前
|
Java 应用服务中间件 Apache
在IntelliJ IDEA中使用Maven配置Tomcat环境
此配置方法具有较高的实用性,简单易懂。遵循以上步骤,您将能顺利在IntelliJ IDEA中使用Maven配置Tomcat环境,从而进行Web项目的开发和调试。
1093 18
|
存储 Java Linux
【Maven】——基础入门,插件安装、配置和简单使用,Maven如何设置国内源
Maven插件安装,Maven项目构建,依赖管理,Haven Help插件,Maven仓库,Maven如何设置国内源
|
Java Shell 应用服务中间件
Mac系统下配置环境变量:Javajdk、maven、tomcat 环境变量配置及对应配置文件
这篇文章介绍了如何在Mac系统下配置Java JDK、Maven和Tomcat的环境变量,包括配置文件的选择、解决环境变量在zsh shell中无效的问题、查看和设置系统环境变量的方法,以及JDK和Maven的下载、配置和测试步骤。
5932 1
Mac系统下配置环境变量:Javajdk、maven、tomcat 环境变量配置及对应配置文件
|
Java jenkins 持续交付
Centos7下docker的jenkins下载并配置jdk与maven
通过上述步骤,您将成功在CentOS 7上的Docker容器中部署了Jenkins,并配置好了JDK与Maven,为持续集成和自动化构建打下了坚实基础。
1022 1
|
6月前
|
Java 区块链 Maven
关于引入maven项目后出现‘parent.relativePath’ of POM错误时的解决方法
关于引入maven项目后出现‘parent.relativePath’ of POM错误时的解决方法
589 3
|
5月前
|
Java jenkins 应用服务中间件
结合Jenkins与Tomcat,实施Maven项目的自动构建和部署流程。
任何项目构建和部署的自动化流程,总离不开对各个环节精细把控与密切配合。涉及到源代码管理、构建工具、持续集成服务器以及最终的运行时环境的协调。通过上述简洁实用的步骤,可以实现Maven项目从源代码到运行状态的无缝过渡,进而提升软件开发的效率与质量。
352 0
|
Java Maven 开发者
maven项目中官方setting.xml文件
`settings.xml` 是 Maven 的配置文件,用于定义用户或全局级别的构建行为。它包含本地仓库路径、网络代理、服务器认证、仓库镜像及构建配置文件等设置,帮助开发者根据环境定制 Maven 行为,提升构建效率与灵活性。
1301 0
|
8月前
|
Java 测试技术 项目管理
【JavaEE】从 0 到 1 掌握 Maven 构建 Java 项目核心技巧 解锁 Java 项目高效管理实用实例
本文从Maven基础概念讲起,涵盖安装配置、核心概念(如POM与依赖管理)及优化技巧。结合Java Web项目实例,演示如何用Maven构建和管理项目,解决常见问题,助你高效掌握这一强大工具,提升Java开发与项目管理能力。适合初学者及进阶开发者学习。资源链接:[点此获取](https://pan.quark.cn/s/14fcf913bae6)。
299 6
|
XML Java 测试技术
从零开始学 Maven:简化 Java 项目的构建与管理
Maven 是一个由 Apache 软件基金会开发的项目管理和构建自动化工具。它主要用在 Java 项目中,但也可以用于其他类型的项目。
721 1
从零开始学 Maven:简化 Java 项目的构建与管理

推荐镜像

更多