Heartsuit's Simple Blog

A place to hold mainly reading notes, and some technical stuff occasionally. 这里主要是一些读书笔记、感悟;还有部分技术相关的内容。


Project maintained by heartsuit Hosted on GitHub Pages — Theme by mattgraham

Maven的.m2目录迁移

目录[-]

Background

Maven 本地仓库默认地址可在settings.xml中找到:

<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
-->

我这里用的是Win7操作系统,.m2目录默认生成在C:\Users\Administrator目录下;然而随着时间推移,这个.m2目录越来越大,现在C盘基本满了。。

Solution

解决方法:移动.m2目录到其他磁盘。

Note:maven环境变量所在目录:E:\apache-maven-3.5.3

修改E:\apache-maven-3.5.3\conf\settings.xml

    <localRepository>E:\.m2\repository</localRepository>

2020-11-22-Maven-m2.jpg

本地仓库位置的配置改变之后,还需要对IDE进行配置,这里以我常用的Idea,VSCode为例,分别配置Maven本地仓库信息。

Ctrl+Alt+S File | Settings | Build, Execution, Deployment | Build Tools | Maven 配置 User settings file: E:\apache-maven-3.5.3\conf\settings.xml Local Repository: E:.m2\repository

2020-11-22-Maven-idea.jpg

Ctrl+, 搜索java.configuration.maven,配置Path to Maven’s settings.xml为E:\apache-maven-3.5.3\conf\settings.xml 选中pom.xml,右键Update project configuration

2020-11-22-Maven-vscode.jpg


If you have any questions or any bugs are found, please feel free to contact me.

Your comments and suggestions are welcome!


「说点什么吧😊~~😊」: