本文主要介紹了maven環境的搭建與idea配置,分享給大家,具體如下:
Maven 下載: http://maven.apache.org/download.cgi
Maven 中央倉庫地址:http://search.maven.org
配置maven環境變量
m2_home:d:\workspace\maven\apache-maven-3.0.5
path:;%m2_home%/bin;
檢查是否成功,打開cmd:
mvn -v
mvn install 會將項目生成的構件安裝到本地maven倉庫
mvn deploy 用來將項目生成的構件分發到遠程maven倉庫
d:\>mvn archetype:generate:在d:盤構建maven標準項目目錄結構
2、settings.xml文件配置
2.0修改本地倉庫位置
m2_home目錄下 conf/settings.xml
1
|
<localrepository>d:/workspace/maven/stone</localrepository> |
2.1如何配置遠程倉庫(私服): (nexus-2.0.4-1-bundle)
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
|
<profiles> <profile> <id>nexus</id> <repositories><!--配置遠程倉庫--> <repository> <id>nexus</id> <name>central repository</name> <url>http: //127.0.0.1/nexus/content/groups/public</url> <releases> <enabled> true </enabled> </releases> <snapshots> <enabled> false </enabled><!----> </snapshots> </repository> </repositories> <pluginrepositories><!--配置maven從什么地方下載插件構件--> <pluginrepository> <id>nexus</id> <name>central repository</name> <url>http: //127.0.0.1/nexus/content/groups/public</url> <releases> <enabled> true </enabled> </releases> <snapshots> <enabled> false </enabled> </snapshots> </pluginrepository> </pluginrepositories> </profile> </profiles> <activeprofiles><!--激活 遠程倉庫--> <activeprofile>nexus</activeprofile> </activeprofiles> |
2.2還可以配置倉庫的鏡像下載
1
2
3
4
5
6
7
|
<mirrors> <mirror><!--配置鏡像--> <id>nexus</id> <mirrorof>*</mirrorof> <url>http: //127.0.0.1/nexus/content/groups/public</url> </mirror> </mirrors> |
3、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
|
<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>xu.feifei</groupid> <artifactid>feifei</artifactid> <packaging>war</packaging> <version> 1.0 </version> <dependencies> <dependency> <groupid>junit</groupid> <artifactid>junit</artifactid> <version> 3.8 . 1 </version> <scope>test</scope> </dependency> <dependency> <groupid>org.json</groupid> <artifactid>json</artifactid> <version> 20090211 </version> </dependency> </dependencies> <build> <finalname>feifei</finalname> </build> </project> |
二、idea的搭建maven相關配置
.
maven項目的包結構
設置maven自動導包
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。
原文鏈接:http://blog.csdn.net/xxb2008/article/details/8772634