Maven by default downloads jar files / dependency libraries under userFolder/.m2
folder
but in case you need to change the download directory to userFolder/JarFiles
Follow below steps –
Let’s say apache maven is downloaded and extracted under userFolder/apache-maven
,
- Navigate to
./apache-maven/conf
- Find & edit settings.xml
- Assume you want Maven to download jar files under
userFolder/JarFiles
, then add below line under <settings…> tag - Save. (mention absolute path)
<localRepository>userFolder/JarFiles/Maven_repo</localRepository>
your settings.xml somewhat looks like below
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <!--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>userFolder/JarFiles</localRepository>
Then,
On Eclipse IDE
- Windows menu > Preferences > Maven > User Settings
- Browse and select the settings.xml and click on apply
On IntelliJ IDEA Editor:
- File > Settings [windows] or Preferences [Mac OS] > Build, Execution… > BuildTools > Maven
- Check the Override check box against “Local repository:”
- Provide the path of new directory
userFolder/JarFiles
and click on apply
Short url – bit.ly/qav-mavenrepositorypath