本文主要介绍了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