前言
IDEA新建項(xiàng)目和pom.xml文件被修改時(shí),右下角都會(huì)出現(xiàn) Maven projects need to be imported(項(xiàng)目需要導(dǎo)入依賴)
如下,點(diǎn)擊 Import Changes導(dǎo)入后,有時(shí)會(huì)一直處于加載中或?qū)胧?/p>
解決方法
第一種方法:
右擊pom.xml文件,選擇Maven中的Reimport重新導(dǎo)入項(xiàng)目依賴,一般這種方法都解決不了上面的問題,可直接看下面的方法
第二種方法:
點(diǎn)擊 File 選擇 Settings… 直接搜索 Maven,在搜索結(jié)果中 Maven home directory:默認(rèn)為Bundled(Maven 3),點(diǎn)擊選擇IDEA自帶的Maven,再點(diǎn)擊應(yīng)用–>OK,重新導(dǎo)入(第一種方法)即可
第三種方法:
若第二種方法還不能解決項(xiàng)目的依賴導(dǎo)入問題,則需要使用國內(nèi)的Maven類庫,IDEA的Maven類庫默認(rèn)都是使用國外的,一些地區(qū)由于墻的原因加載會(huì)很慢或者加載不了,此時(shí)可以導(dǎo)入阿里云的 Maven 類庫(一個(gè)settings_aliyun.xml文件)來使用,我就是用這個(gè)方法才解決的
pom.xml文件內(nèi)容
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
|
< 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.tcl.kuyu.salesreport</ groupId > < artifactId >salesreport-server</ artifactId > < packaging >war</ packaging > < version >1.0-SNAPSHOT</ version > < name >salesreport-server</ name > < url >http://maven.apache.org</ url > <!-- 剛開始的時(shí)候,我很不習(xí)慣,也不太理解為什么要用下面的標(biāo)簽,后來才覺得,代碼就該這樣。。。修改的時(shí)候也會(huì)特別的方便 --> < properties > < aspectj.version >1.8.9</ aspectj.version > < java.version >1.8</ java.version > < junit.version >4.12</ junit.version > < logback.version >1.1.7</ logback.version > < logback-ext-spring.version >0.1.4</ logback-ext-spring.version > < mysql.driver.version >5.1.38</ mysql.driver.version > < slf4j.version >1.7.21</ slf4j.version > < spring.version >4.2.5.RELEASE</ spring.version > < jackson.version >2.5.2</ jackson.version > < mybatis.version >3.4.0</ mybatis.version > < mybatis.spring.version >1.3.0</ mybatis.spring.version > < mybatis-plus.version >1.2.16</ mybatis-plus.version > < fastjson.version >1.2.11</ fastjson.version > < shiro.version >1.2.6</ shiro.version > < project.build.sourceEncoding >UTF-8</ project.build.sourceEncoding > < jetty.web.xml >${basedir}/jetty-webdefault.xml</ jetty.web.xml > </ properties > < dependencies > <!-- junit 此處是單元測(cè)試的依賴--> < dependency > < groupId >junit</ groupId > < artifactId >junit</ artifactId > < version >${junit.version}</ version > < scope >test</ scope > </ dependency > < dependency > < groupId >junitperf</ groupId > < artifactId >junitperf</ artifactId > < version >1.8</ version > < scope >test</ scope > </ dependency > <!-- spring --> < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-aop</ artifactId > < version >${spring.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-aspects</ artifactId > < version >${spring.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-beans</ artifactId > < version >${spring.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-context</ artifactId > < version >${spring.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-context-support</ artifactId > < version >${spring.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-core</ artifactId > < version >${spring.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-expression</ artifactId > < version >${spring.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-jdbc</ artifactId > < version >${spring.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-jms</ artifactId > < version >${spring.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-orm</ artifactId > < version >${spring.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-oxm</ artifactId > < version >${spring.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-test</ artifactId > < version >${spring.version}</ version > < scope >test</ scope > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-tx</ artifactId > < version >${spring.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-web</ artifactId > < version >${spring.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-webmvc</ artifactId > < version >${spring.version}</ version > </ dependency > < dependency > < groupId >commons-dbcp</ groupId > < artifactId >commons-dbcp</ artifactId > < version >1.4</ version > </ dependency > <!-- freemark 根據(jù)項(xiàng)目需要,簡(jiǎn)單的web項(xiàng)目的話此處是不需要的--> < dependency > < groupId >org.freemarker</ groupId > < artifactId >freemarker</ artifactId > < version >[2.3.19,2.4)</ version > </ dependency > < dependency > < groupId >commons-httpclient</ groupId > < artifactId >commons-httpclient</ artifactId > < version >3.1</ version > </ dependency > < dependency > < groupId >org.apache.commons</ groupId > < artifactId >commons-lang3</ artifactId > < version >3.1</ version > </ dependency > < dependency > < groupId >commons-collections</ groupId > < artifactId >commons-collections</ artifactId > < version >3.2.2</ version > </ dependency > < dependency > < groupId >com.alibaba</ groupId > < artifactId >fastjson</ artifactId > < version >${fastjson.version}</ version > </ dependency > <!-- logback begin --> < dependency > < groupId >org.slf4j</ groupId > < artifactId >slf4j-api</ artifactId > < version >${slf4j.version}</ version > </ dependency > < dependency > < groupId >ch.qos.logback</ groupId > < artifactId >logback-core</ artifactId > < version >${logback.version}</ version > </ dependency > < dependency > < groupId >ch.qos.logback</ groupId > < artifactId >logback-classic</ artifactId > < version >${logback.version}</ version > </ dependency > <!-- logback end --> < dependency > < groupId >org.aspectj</ groupId > < artifactId >aspectjrt</ artifactId > < version >${aspectj.version}</ version > </ dependency > < dependency > < groupId >org.aspectj</ groupId > < artifactId >aspectjweaver</ artifactId > < version >${aspectj.version}</ version > </ dependency > < dependency > < groupId >mysql</ groupId > < artifactId >mysql-connector-java</ artifactId > < version >${mysql.driver.version}</ version > </ dependency > < dependency > < groupId >org.mybatis</ groupId > < artifactId >mybatis</ artifactId > < version >${mybatis.version}</ version > </ dependency > < dependency > < groupId >org.mybatis</ groupId > < artifactId >mybatis-spring</ artifactId > < version >${mybatis.spring.version}</ version > </ dependency > < dependency > < groupId >com.baomidou</ groupId > < artifactId >mybatis-plus</ artifactId > < version >${mybatis-plus.version}</ version > </ dependency > < dependency > < groupId >com.fasterxml.jackson.core</ groupId > < artifactId >jackson-databind</ artifactId > < version >${jackson.version}</ version > </ dependency > < dependency > < groupId >com.fasterxml.jackson.core</ groupId > < artifactId >jackson-core</ artifactId > < version >${jackson.version}</ version > </ dependency > < dependency > < groupId >commons-fileupload</ groupId > < artifactId >commons-fileupload</ artifactId > < version >1.3.1</ version > </ dependency > < dependency > < groupId >javax.servlet.jsp</ groupId > < artifactId >jsp-api</ artifactId > < version >2.2</ version > < scope >provided</ scope > </ dependency > < dependency > < groupId >javax.servlet</ groupId > < artifactId >servlet-api</ artifactId > < version >2.5</ version > < scope >provided</ scope > </ dependency > < dependency > < groupId >com.mangofactory</ groupId > < artifactId >swagger-springmvc</ artifactId > < version >1.0.2</ version > </ dependency > < dependency > < groupId >com.fasterxml.jackson.core</ groupId > < artifactId >jackson-annotations</ artifactId > < version >${jackson.version}</ version > </ dependency > < dependency > < groupId >com.alibaba</ groupId > < artifactId >druid</ artifactId > < version >1.0.18</ version > </ dependency > < dependency > < groupId >javassist</ groupId > < artifactId >javassist</ artifactId > < version >3.12.1.GA</ version > </ dependency > <!-- shiro權(quán)限管理 --> < dependency > < groupId >org.apache.shiro</ groupId > < artifactId >shiro-core</ artifactId > < version >${shiro.version}</ version > </ dependency > < dependency > < groupId >org.apache.shiro</ groupId > < artifactId >shiro-web</ artifactId > < version >${shiro.version}</ version > </ dependency > <!-- 如果要與spring集成,需要添加此依賴 --> < dependency > < groupId >org.apache.shiro</ groupId > < artifactId >shiro-spring</ artifactId > < version >${shiro.version}</ version > </ dependency > <!-- shiro權(quán)限管理 --> </ dependencies > < build > < finalName >salesreport</ finalName > <!--下面的resources里面的配置,大家可以根據(jù)自身項(xiàng)目需要進(jìn)行選擇和修改--> < resources > < resource > < directory >src/main/resources/commons</ directory > < filtering >true</ filtering > < includes > < include >**/*.*</ include > </ includes > </ resource > < resource > < directory >src/main/resources/${env}</ directory > < filtering >true</ filtering > < includes > < include >**/*.*</ include > </ includes > </ resource > </ resources > < plugins > <!-- 編譯插件 --> < plugin > < artifactId >maven-compiler-plugin</ artifactId > < configuration > < source >1.8</ source > < target >1.8</ target > < encoding >UTF-8</ encoding > </ configuration > </ plugin > <!-- 單元測(cè)試插件 --> < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-surefire-plugin</ artifactId > < version >2.19</ version > < configuration > < skipTests >true</ skipTests > </ configuration > </ plugin > <!--jetty 插件,mvn jetty:run --> < plugin > < groupId >org.eclipse.jetty</ groupId > < artifactId >jetty-maven-plugin</ artifactId > < version >9.3.7.v20160115</ version > < configuration > < webApp > < webDefaultXml >${jetty.web.xml}</ webDefaultXml > < contextPath >/</ contextPath > < descriptor >${basedir}/src/main/webapp/WEB-INF/web.xml</ descriptor > </ webApp > < stopKey >exit</ stopKey > < stopPort >9091</ stopPort > < webAppSourceDirectory >${project.basedir}/src/main/webapp</ webAppSourceDirectory > < scanIntervalSeconds >0</ scanIntervalSeconds > < httpConnector > < port >8080</ port > </ httpConnector > </ configuration > </ plugin > </ plugins > </ build > < profiles > < profile > < id >dev</ id > < activation > < activeByDefault >true</ activeByDefault > </ activation > < properties > < env >dev</ env > </ properties > </ profile > < profile > < id >sit</ id > < properties > < env >sit</ env > </ properties > </ profile > < profile > < id >prod</ id > < properties > < env >prod</ env > </ properties > </ profile > < profile > < id >uat</ id > < properties > < env >uat</ env > </ properties > </ profile > </ profiles > </ project > |
導(dǎo)入xml文件:進(jìn)入第二種方法的 Maven 界面勾選右側(cè)第一個(gè)Override
按第一種方法重新導(dǎo)入一下即可
至此,Sync出現(xiàn)綠√即導(dǎo)入項(xiàng)目依賴成功啦!
到此這篇關(guān)于IDEA項(xiàng)目的依賴(pom.xml文件)導(dǎo)入問題及解決的文章就介紹到這了,更多相關(guān)IDEA pom.xml文件導(dǎo)入內(nèi)容請(qǐng)搜索服務(wù)器之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持服務(wù)器之家!
原文鏈接:https://blog.csdn.net/weixin_42365530/article/details/104240956