第一步:版本对应
我使用的是idea2021.1和maven的版本是3.6.3版本,最新的3.6.8版本也测试过,用下面的方法都可以实现。
第二步:下载maven
百度搜索maven下载
进入官网之后选择下载这个,之后放入指定的路径,进行解压
第三步:进行镜像配置
在刚刚解压的文件夹中找到这个conf文件夹,点击进入
进去之后选中setting.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.
|-->
这个位置,这个是注释,我们将我们要配置的maven镜像粘贴到他的下面
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>aliyun-nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
<mirror>
<!--This is used to direct the public snapshots repo in the
profile below over to a different nexus group -->
<id>aliyun-nexus-public-snapshots</id>
<mirrorOf>public-snapshots</mirrorOf>
<url>http://maven.aliyun.com/nexus/content/repositories/snapshots/</url>
</mirror>
</mirrors>
这是我用的阿里云镜像
第四步:设置我们的maven仓库用来存放jar包
在一开始的目录下创建一个maven-repo文件夹
用来存放我们从远程下载来的jar包,之后再setting.xml中进行配置,将从远程maven仓库中下载的jar包放入到指定的路径。
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
<localRepository>E:\apache-maven-3.6.3\maven-repo</localRepository>
这个位置大概在上面,主要是找到上面那个注释的位置,然后将代码复制过去,当然这个路劲是我的路径, 你需要将路径改成你自己的路径,路径指向是刚刚创建的maven-repo这个文件夹
这样我们的maven就配置好了
第五步:在idea中使用maven
第六步:需要在maven中忽略ssl
将一下代码拷贝入import中
-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true
这样maven就设置好了,我们直接创建maven项目可以试一试,或者是创建一个springboot项目。