1.使用maven之前,先要配置maven的环境
下载 apache-maven-3.2.3.zip,解压到指定文件夹下
配置maven环境变量,我本地已经配置好了
新建系统变量 MAVEN_HOME 变量值:D:\Program Files\apache-maven-3.2.3
编辑系统变量 PATH 添加变量值: ;%MAVEN_HOME%\bin
查看配置成功,cmd界面输入 mvn -v 出现如下提示说明成功了
2.安装Nexus Repository(私服库)
下载安装包地址 http://www.sonatype.org/nexus/go
相关安装文章 http://www.cnblogs.com/quanyongan/archive/2013/04/24/3037589.html)
3.修改maven的setttings配置
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>D:/mavenRepository</localRepository>
<servers>
<server>
<id>releases</id>
<username>deployment</username>
<password>deployment123</password>
</server>
<server>
<id>snapshots</id>
<username>deployment</username>
<password>deployment123</password>
</server>
</servers>
<mirrors>
<mirror>
<id>releases</id>
<mirrorOf>*</mirrorOf>
<url>http://<span style="color: rgb(255, 0, 0); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px;">localhost:8081</span>/nexus/content/groups/public</url>
</mirror>
<mirror>
<id>snapshots</id>
<mirrorOf>*</mirrorOf>
<url>http://<span style="color: rgb(255, 0, 0); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px;">localhost:8081</span>/nexus/content/groups/public-snapshots</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>hostenv</id>
<properties>
<host.url>http://172.18.243.114:8090</host.url>
</properties>
</profile>
<profile>
<id>dev</id>
<properties>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>hostenv</activeProfile>
<activeProfile>dev</activeProfile>
</activeProfiles>
</settings>
4.eclipse引入setting.xml文件
步骤如下: eclipse -》widows-》preferences-》maven
5.创建maven项目
右击project空白处》new》other,然后选择Maven Project ,点 next
勾选 Create a simple project
输入分组及项目名称,packing选择war
点击finish 完成图示,项目结构如下图,如果src/main没有webapp需手动创建这个文件夹
我手动创建了WEB-INF目录,并创建了web.xml和index.jsp两个文件
此时本打算发布到tomcat,但发现web.xml文件报错,查看了后发现少了javax.servlet-api-xxx.jar,
这时,还需编辑pom.xml文件,引入项目所需的jar
4.0.0
com.daxiong
myMavenWeb
0.0.1-SNAPSHOT
war
http://maven.apache.org
javax.servlet
javax.servlet-api
3.0.1
org.springframework
spring-core
4.2.2.RELEASE
org.springframework
spring-context
4.2.2.RELEASE
org.springframework
spring-tx
4.2.2.RELEASE
org.springframework
spring-jdbc
4.2.2.RELEASE
org.springframework
spring-test
4.2.2.RELEASE
org.springframework
spring-web
4.2.2.RELEASE
org.aspectj
aspectjweaver
1.8.5
org.springframework
spring-aop
4.2.2.RELEASE
org.springframework
spring-webmvc
4.2.2.RELEASE
到此,简单maven项目就创建完了,还可以创建多个maven项目,可以相互依赖,只是我还在研究中。。