Maven:优秀的构建工具
依赖java
一、下载
maven:官网,http://maven.apache.org/
maven3.1.1:http://maven.apache.org/download.cgi
二、解压,例如:D:\apache-maven-3.1.1
三、配置环境变量
MAVEN_HOME:D:\apache-maven-3.1.1
MAVEN:%MAVEN_HOME%\bin
MAVEN_OPTS:-Xms256m -Xmx512m (可选)
添加到path:%MAVEN%
检测是否成功 cmd.exe ----> mvn -version
四、配置maven配置文件、项目
1、修改m2的配置目录D:\apache-maven-3.1.1\bin\m2.conf
set maven.home default ${user.home}/m2 ------>set maven.home default ${maven.home}/m2
默认为当前用户,
2、修改repository的配置目录D:\apache-maven-3.1.1\conf\settings.xml
a、找到该标签<localRepository>/path/to/local/repo</localRepository>
修改为:<localRepository>D:/apache-maven-3.1.1/repo</localRepository>
b、找到<servers>标签
在其中加入:
<server> <id>nexus-releases</id> <username>admin</username> <password>admin</password> </server> <server> <id>nexus-snapshots</id> <username>admin</username> <password>admin</password> </server>
c、找到<profiles>标签
在其中加入:
<profile> <id>spring</id> <repositories> <repository> <id>springsourcerepo</id> <name>SpringSource Repository</name> <url>http://repo.springsource.org/release</url> </repository> </repositories> </profile> <profile> <id>dev</id> <repositories> <repository> <id>nexus</id> <url>http://172.16.10.59:8081/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus</id> <url>http://172.16.10.59:8081/nexus/content/groups/public</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile>
以上这段可参考:http://wenku.baidu.com/link?url=ZvbHFA2Rx_817I17t6_Ee7cEnb3415MH5ChpKNMPDwtZficpZvKUHVwECQdH7oVx_TXwvnhGuQS5HmGLh0voWb8J_O62eO_uf5tJ947msuC
d、找到<profiles>标签
<pluginGroups>中加入:<pluginGroup>org.mortbay.jetty</pluginGroup>
五、生成自己的maven项目
运行cmd.exe--->进入要建立项目的目录------->执行
mvn archetype:create -DgroupId=com.demo.app -DartifactId=demo-app