maven在eclipse中的配置

maven是个工具,可以自动下载项目依赖库(jar包)

pom.xml是整个maven系统的基本单元

仓库资源:https://mvnrepository.com

先在官网下载maven然后把它放在自己的文件夹

 

我放在的是E盘

然后打开环境变量的配置:

 

配置好环境变量以后,我们配置maven:

1.修改本地仓库位置

打开maven解压的文件夹,在里面创一个本地仓库localRepository

 然后打开conf文件夹里面的settings.xml 用记事本打开,把黑色剪头里面的注释复制出来,把路径改成刚刚创的那个本地仓库的路径。

 

2.修改镜像位置:

镜像位置代码如下,也是在settings.xml里面,我把之前的镜像给注释掉了。


  <!-- mirrors
   | This is a list of mirrors to be used in downloading artifacts from remote repositories.
   |
   | It works like this: a POM may declare a repository to use in resolving certain artifacts.
   | However, this repository may have problems with heavy traffic at times, so people have mirrored
   | it to several places.
   |
   | That repository definition will have a unique id, so we can create a mirror reference for that
   | repository, to be used as an alternate download site. The mirror site will be the preferred
   | server for that repository.
   |-->
  <mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
	 
	 <!-- 阿里云仓库 -->
	<mirror>
		<id>alimaven</id>
		<mirrorOf>central</mirrorOf>
		<name>aliyun maven</name>
		<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
	</mirror>
	
    <mirror>
      <id>maven-default-http-blocker</id>
      <mirrorOf>external:http:*</mirrorOf>
      <name>Pseudo repository to mirror external repositories initially using HTTP.</name>
      <url>http://0.0.0.0/</url>
      <blocked>true</blocked>
    </mirror>
  </mirrors>

修改好以后打开eclipse:

 按照图片上的步骤window-->Maven-->Installations-->Add

把maven给添加进来

选择刚刚maven解压的文件点击finish。

添加进来之后把maven给勾上

然后到User Settings图片上剪头的都按路径选上,第四步是刚刚创的本地仓库的路径好了之后点击ok

 

然后就算是配置好了maven,可以把依赖导入pom.xml测试一下

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值