maven基础设置
打开maven目录中的conf文件夹,找到settings.xml文件,该文件为maven的全局配置文件
1.配置本地仓库
maven首先会在本地仓库进行依赖(jar包)检索,当发现本地仓库不存在,通过settings.xml的配置去访问远程中央仓库或者私服(镜像仓库)去下载,下载至本地仓库中再使用

在maven文件夹中新建文件夹repository作为本地仓库(也可以在其他位置)
本文本地仓库位置即为E:\apache-maven-3.6.0\repository
在setting.xml中的<settings>节点中追加配置
<localRepository>E:\apache-maven-3.6.0\repository</localRepository>

2.配置中央仓库或者镜像仓库
maven的默认中央仓库是: http://repo1.maven.org/maven2
这个网址位于国外,有些时候连接不稳定,可以通过在<mirrors>节点下追加下方配置设置国内阿里云的镜像仓库
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
eclipse集成maven
1.打开eclipse,找到window->preferences

2.搜索maven

3.在Installations中设置使用本地maven
(1)点击"Add"

(2)点击"Directory"选择maven安装路径



(3)勾选使用本地maven

(4)在User Settings中设置配置文件

(5)点击"Apply and Close"完成集成
网友评论