由于maven依赖下载龟速,查看网上教程配置了几次maven失败之后发现了一个简单的配置方法,特此记录下来。

1.首先打开idea,选中setting设置

2.点击进入后,选中Maven栏目,其中Maven home Path我们不用改,直接用IDEA自带的。先点击User setting file栏目旁的小勾钩,把勾勾打上,然后打开这个文件的文件夹

3.如果文件夹中存在文件,则编辑maven镜像或替换文件,,如果文件夹中没有setting.xml文件,则我们给他加上。

setting.xml整个文件代码如下:

<!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ${user.home}/.m2/repositoryD:\apache-maven-3.8.5-bin\repository--><!-- interactiveMode | This will determine whether maven prompts you when it needs input. If set to false, | maven will use a sensible default value, perhaps based on some other setting, for | the parameter in question. | | Default: truetrue--><!-- offline | Determines whether maven should attempt to connect to the network when executing a build. | This will have an effect on artifact downloads, artifact deployment, and others. | | Default: falsefalse--><!-- pluginGroup | Specifies a further group identifier to use for plugin lookup.com.your.plugins--><!-- proxy | Specification for one proxy, to be used in connecting to the network. |optionaltruehttpproxyuserproxypassproxy.host.net80local.net|some.host.com--><!-- server | Specifies the authentication information to use when connecting to a particular server, identified by | a unique name within the system (referred to by the 'id' attribute below). | | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are | used together. |deploymentReporepouserrepopwd--><!-- Another sample, using keys to authenticate.siteServer/path/to/private/keyoptional; leave empty if not used.--><!-- 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. |mirrorIdrepositoryIdHuman Readable Name for this Mirror.http://my.repository.com/repo/path --><!-- maven-default-http-blockerexternal:http:*Pseudo repository to mirror external repositories initially using HTTP.http://0.0.0.0/true--> aliyunmaven*阿里云公共仓库https://maven.aliyun.com/repository/public<!-- profile | Specifies a set of introductions to the build process, to be activated using one or more of the | mechanisms described above. For inheritance purposes, and to activate profiles via| or the command line, profiles have to have an ID that is unique. | | An encouraged best practice for profile identification is to use a consistent naming convention | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc. | This will make it more intuitive to understand what the set of introduced profiles is attempting | to accomplish, particularly when you only have a list of profile id's for debug. | | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.jdk-1.41.4jdk14Repository for JDK 1.4 buildshttp://www.myhost.com/maven/jdk14defaultalways--><!-- | Here is another profile, activated by the system property 'target-env' with a value of 'dev', | which provides a specific path to the Tomcat instance. To use this, your plugin configuration | might hypothetically look like: | | ... |  | org.myco.myplugins | myplugin | |  | ${tomcatPath} |  |  | ... | | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to | anything, you could just leave off the  inside the activation-property. |env-devtarget-envdev/path/to/tomcat/instance--> jdk-dev true1.8  1.81.81.8 <!-- activeProfiles | List of profiles that are active for all builds. |alwaysActiveProfileanotherAlwaysActiveProfile-->

镜像代码:

 aliyunmaven*阿里云公共仓库https://maven.aliyun.com/repository/public

4. 配置完之后,在idea中确定选中并应用了后再点击Importing找到对应选项添加相应语句

语句如下:

-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true

5.应用并退出,刷新maven,查看下载依赖速度。若成功,下载速度会明显变快。