maven入门学习

来源:互联网 发布:数据分布图怎么做spss 编辑:程序博客网 时间:2024/06/06 10:05

1.Download maven 路径:http://labs.renren.com/apache-mirror/maven/binaries/apache-maven-3.0.4-bin.tar.gz

2. unzip the Unzip the distribution archive to C:\Program Files\Apache Software Foundation(recommond)

3. Add the M2_HOME environment variable by opening up the system properties:

计算机-〉高级属性设置->高级-〉环境变量->...变量:M2_HOME, 变量值:C:\Program Files\Apache Software Foundation\apache-maven-3.0.4

4.将%M2_HOME%\bin加入到path变量中。

5.在cmd终端输入:mvn --version测试maven是否成功。

###################################################################################################################

关于localRepository文件的配置:

win7系统path:C:\Users\Yunlong\.m2下面有repository和settings.xml两个文件。

下面重点讲解settings.xml的相关配置:

官方学习地址:http://maven.apache.org/settings.html

There are two locations where a settings.xml file may live:

  • The Maven install: $M2_HOME/conf/settings.xml
  • A user's install: ${user.home}/.m2/settings.xml

such as:

A user's install: ${user.home}/.m2/settings.xml

<settings>
  <proxies>
   <proxy>
      <active>true</active>
      <protocol>http</protocol>
      <host>172.16.1.53</host>
      <port>8080</port>
      <username></username>
      <password></password>
      <nonProxyHosts>172.*|192.*|localhost|127.0.0.1</nonProxyHosts>
    </proxy>
  </proxies>
</settings>

######################################################################################################

在eclipse中集成maven:

Update Sites

Latest m2e release (recommended)

1.

http://download.eclipse.org/technology/m2e/releases(eclipse->help->Install New Software->work with输入以上网址)

http://wiki.eclipse.org/M2E_updatesite_and_gittags

2.重启eclipse在Windows->Preferences里会看到多了一个maven选项。点击Maven-〉User Settings选择自己本地的settings.xml路径:如C:\Users\Yunlong\.m2\settings.xml

点击ok即可。

3.import->Existing Maven Project然后选择自己svn下载项目所在的本地路径如:D:\upanalytics,eclipse会自动找到相关的maven项目。

4.导入完项目就可以右键点击pom.xml运行如mvn clean install相关的命令。

5.如果项目中需要增加新的jar,可以直接打开pom.xml->Dependencies->add->Enter groupid,artifactId,or sha1 prefix or Pattern(*)下面的框中输入相关的信息让maven自动查找相关jar。

 #####################################################################################

开发环境搭建步骤,供参考:
 
1.安装eclipse maven 插件
通过Eclipse在线更新网址:m2eclipse Core Update Site: 
http://m2eclipse.sonatype.org/sites/m2e
 
2.将附件中的settings.xml拷贝到C:\Documents and Settings\yuening(用户名)\.m2 文件夹下(若插件安装成功,则该文件夹已经生成)
 
2.将所有upop项目从文件夹目录中check out 到 本地(从文件系统,非利用eclipse)
 
3.在eclipse中导入项目
右键-->import-->,Marven--->Exsisting Maven Projects选择第2部check out下的项目
 
4.重启eclipse,maven会自动下载依赖的jar包
 
5.完成

0 0
原创粉丝点击