Maven安装与配置,整合Eclipse

1.安装java jdk
2.下载Maven
安装到本机
1 将下载回来的包解压到任意地址,我的路径是D:\Program Files\apache-maven-3.0.3
2 新建环境变量M2_HOME 指向D:\Program Files\apache-maven-3.0.3
3 在path尾部添加%M2_HOME%\bin
4检查是否安装成功
打开cmd
echo %M2_HOME%
mnv –v
如下图:


插件m2eclipse的安装
下载插件eclipse-maven3-plugin,http://www.downcc.com/soft/17592.html
解压到..\MyEclipse 10\dropins


配置本地仓库
找到maven下的conf 下settings.xml 配置文件,例如:D:\Server\maven\conf\settings.xml
我们程序所需要的jar包等会先去本地仓库找,如果找不到则会去网络上的的中央仓库下载,当然默认本地仓库是放在c盘用户下.m2文件夹,这里我们可以打开.m2的settings.xml进行修改

这里我们指定本地仓库位于D盘的MavenRepository文件夹下

配置远程中央仓库
方法1:配置/conf/settings.xml
<mirrors>
<mirror>
  <id>alimaven</id>
  <name>aliyun maven</name>
  <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
  <mirrorOf>central</mirrorOf>
</mirror>
<mirror>
  <id>uk</id>
  <name>Human Readable Name for this Mirror.</name>
  <url>http://uk.maven.org/maven2/</url>
  <mirrorOf>central</mirrorOf>
</mirror>
<mirror>
  <id>CN</id>
  <name>OSChina Central</name>
  <url>http://maven.oschina.net/content/groups/public/</url>
  <mirrorOf>central</mirrorOf>
</mirror>
<mirror>
  <id>nexus</id>
  <name>internal nexus repository</name>
  <url>http://repo.maven.apache.org/maven2</url>
  <mirrorOf>central</mirrorOf>
</mirror>
</mirrors>

方法2:配置项目pom.xml
<repositories>
           <repository>
                <id> alimaven</id>
                <name> aliyun maven</name>
                <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
                <releases>
                     <enabled>true</enabled>
                </releases>
                <snapshots>
                     <enabled>false</enabled>
                </snapshots>
           </repository>
</repositories>
<pluginRepositories>
           <pluginRepository>
                <id> alimaven</id>
                <name> aliyun maven</name>
                <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
                <releases>
                     <enabled>true</enabled>
                </releases>
                <snapshots>
                     <enabled>false</enabled>
                </snapshots>
           </pluginRepository>
</pluginRepositories>

参考资料:
1.Maven基础-默认中央仓库[settings.xml 配置详解] http://blog.youkuaiyun.com/yiluoak_47/article/details/12068855/
2.maven如何修改本地仓库与中央仓库 https://my.oschina.net/ghm7753/blog/373350
3. maven 安装jar包对应pom.xml的dependency查询网址:http://mvnrepository.com/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值