eclipse+Maven开发环境搭建

最近研究了下maven构建项目,确实使用比较方便。学习了pom文件结构和maven的生命周期后,自己建了个maven工程,下面记录下开发环境搭建步骤。

【1】 首先在本机安装个maven,不要使用eclipse自带的maven插件,直接在http://maven.apache.org/获取安装包,参照里面的步骤设置环境变量,设置完后可以在命令行里面用set命令查看下是否生效,比如set path可以查看path,就跟linux下用echo查看环境变量一样。

  1. Unzip the distribution archive, i.e. apache-maven-3.1.1-bin.zip to the directory you wish to install Maven 3.1.1. These instructions assume you choseC:\Program Files\Apache Software Foundation. The subdirectory apache-maven-3.1.1 will be created from the archive.
  2. Add the M2_HOME environment variable by opening up the system properties (WinKey + Pause), selecting the "Advanced" tab, and the "Environment Variables" button, then adding the M2_HOME variable in the user variables with the value C:\Program Files\Apache Software Foundation\apache-maven-3.1.1. Be sure to omit any quotation marks around the path even if it contains spaces. Note: For Maven   2.0.9, also be sure that the M2_HOMEdoesn't have a '\' as last character.
  3. In the same dialog, add the M2 environment variable in the user variables with the value %M2_HOME%\bin.
  4. Optional: In the same dialog, add the MAVEN_OPTS environment variable in the user variables to specify JVM properties, e.g. the value -Xms256m -Xmx512m. This environment variable can be used to supply extra options to Maven.
  5. In the same dialog, update/create the Path environment variable in the user variables and prepend the value %M2% to add Maven available in the command line.
  6. In the same dialog, make sure that JAVA_HOME exists in your user variables or in the system variables and it is set to the location of your JDK, e.g.C:\Program Files\Java\jdk1.5.0_02 and that %JAVA_HOME%\bin is in your Path environment variable.
  7. Open a new command prompt (Winkey + R then type cmd) and run mvn --version to verify that it is correctly installed.
安装后,设置下eclipse里面的maven路径,选择下setting配置文件

注意settings.xml中本地仓库路径的设定<localRepository>E:/repository</localRepository>,其他的一些配置这里先不提了。


【2】上述步骤完成后,就可以新建Maven工程了,新建maven工程,下图选择的是webapp工程,下面输入Group Id和Artifact Id即可完成工程的创建


【3】选中项目根节点新建source folder目录,典型的目录结构如下图


配置java文件编译后class目标文件的保存路径


【4】右键工程,选择Run as Maven install即可生成war包

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值