对于maven之前一直遇到这两个问题,第一呢是创建速度太慢,每次都要等很久很久,有时候超过半个小时;第二个呢是每次在用IDEA创建新的项目时,maven配置总是会恢复默认配置,有时idea的本地仓库会报error,就像这样:
![1cfb6bfab557b5fd0008b4cbd72ae5e0.png](https://img-blog.csdnimg.cn/img_convert/1cfb6bfab557b5fd0008b4cbd72ae5e0.png)
关于这两个问题困扰了我超级之久,查了很多资料,接下来说说解决方案。
- 修改maven的本地仓库
- maven创建速度过慢 问题解决
- 每次重新打开IDEA,本地仓库恢复默认及Type为error问题解决
修改maven的本地仓库
找到下好的maven,找到conf下的settings.xml并打开
![7892d2a802ddbeafb3c1785a2aa365a7.png](https://img-blog.csdnimg.cn/img_convert/7892d2a802ddbeafb3c1785a2aa365a7.png)
在这里修改自己本地仓库的位置
![f010f664ac57bfe6e75ca48f37ed3e54.png](https://img-blog.csdnimg.cn/img_convert/f010f664ac57bfe6e75ca48f37ed3e54.png)
并添加阿里云镜像
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
打开IDEA---settings---Build,Execution,Deployment---Build Tools---Maven
![1159613d70fe6aa63f23e03f9beaae9a.png](https://img-blog.csdnimg.cn/img_convert/1159613d70fe6aa63f23e03f9beaae9a.png)
settings file就是自己settings.xml的位置,local repository就是自己本地仓库的位置。修改完成后点击Apply,ok。
每次重新打开IDEA,本地仓库恢复默认及Type为error问题解决
IDEA2019.3版本需要修改project.default.xml,C:Users你的用户名.IntelliJIdea2019.3configoptionproject.default.xml
![f6c146feea639f1041950799a26c597c.png](https://img-blog.csdnimg.cn/img_convert/f6c146feea639f1041950799a26c597c.png)
打开,添加,添加完后保存即可
<component name="MavenImportPreferences">
<option name="generalSettings">
<MavenGeneralSettings>
<option name="localRepository" value="这里是你自己的local repository路径,例如(C:ideaMavenMavenRepository)" />
<option name="mavenHome" value="这里是你自己的maven Home路径,例如(C:ideaMavenapache-maven-3.6.1)" />
<option name="userSettingsFile" value="这里是你自己的user Settings File路径,例如(C:ideaMavenapache-maven-3.6.1confsettings.xml)" />
</MavenGeneralSettings>
</option>
</component>
maven创建速度过慢 问题解决
打开IDEA---settings---Build,Execution,Deployment---Build Tools---Maven---Runner,添加-DarchetypeCatalog=internal,如图所示:
![7aadf29aeb66eae3bb8077e1aa4d80eb.png](https://img-blog.csdnimg.cn/img_convert/7aadf29aeb66eae3bb8077e1aa4d80eb.png)
最后点击Apply,OK.
找了很多资料花了很长时间,亲测有效。
参考文章链接
IDEA重新打开project,maven本地仓库配置又变了,完美解决方法_Java_weixin_44377911的博客-CSDN博客blog.csdn.net![92995f980231795021e72d2f5f3222e6.png](https://img-blog.csdnimg.cn/img_convert/92995f980231795021e72d2f5f3222e6.png)