Maven環(huán)境的搭建與idea配置
Maven 下載: http://maven./download.cgi
Maven 中央倉庫地址:http://search.
配置maven環(huán)境變量
M2_HOME:D:\workspace\maven\apache-maven-3.0.5
Path:;%M2_HOME%/bin;
檢查是否成功,打開CMD:
Mvn -v
mvn install 會將項目生成的構(gòu)件安裝到本地Maven倉庫
mvn deploy 用來將項目生成的構(gòu)件分發(fā)到遠(yuǎn)程Maven倉庫
D:\>mvn archetype:generate:在D:盤構(gòu)建maven標(biāo)準(zhǔn)項目目錄結(jié)構(gòu)
2、settings.xml文件配置
2.0修改本地倉庫位置
M2_home目錄下 conf/settings.xml
-
<localRepository>D:/workspace/maven/stone</localRepository>
2.1如何配置遠(yuǎn)程倉庫(私服): (nexus-2.0.4-1-bundle)
-
<profiles>
-
<profile>
-
<id>nexus</id>
-
<repositories><!--配置遠(yuǎn)程倉庫-->
-
<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從什么地方下載插件構(gòu)件-->
-
<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><!--激活 遠(yuǎn)程倉庫-->
-
<activeProfile>nexus</activeProfile>
-
</activeProfiles>
-------------------------------------------------------------------------------------------------
2.2還可以配置倉庫的鏡像下載
-
<mirrors>
-
<mirror><!--配置鏡像-->
-
<id>nexus</id>
-
<mirrorOf>*</mirrorOf>
-
<url>http://127.0.0.1/nexus/content/groups/public</url>
-
</mirror>
-
</mirrors>
3、pom.xml文件配置依賴
-
<project xmlns="http://maven./POM/4.0.0" xmlns:xsi="http://www./2001/XMLSchema-instance"
-
xsi:schemaLocation="http://maven./POM/4.0.0 http://maven./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相關(guān)配置
.
maven項目的包結(jié)構(gòu)
設(shè)置maven自動導(dǎo)包
|