Coming from npm/yarn
background, for each and every project we will have node_modules
which holds all the dependencies and libraries, if we wish to reset our project from clean state, we can always delete the entire node_modules
and reinstall the libraries.
rm -rf node_modules/ && yarn cache clean && yarn install
Now trying to learn Java and trying out Maven
, correct me if I'm wrong, we define the dependencies on pom.xml
, which essentially the same as package.json
on yarn/npm
, and the downloaded dependencies will be stored on /target
?
Is /target
equals to node_modules
and hence I can actually delete entire /target
and restart the downloading process?
The dependencies are not stored in target
, but in .m2/repository
in your user directory. This is the so-called local repository . It also holds all artifacts build on that computer/account.
You can delete it if necessary and only lose your local builds.
The target
directory, on the other hand, gathers the (intermediate and final) results of a build. It can also be deleted, usually by using mvn clean
.
You can delete the .m2 folder lying in the below location somewhat and then do update maven project.You can also do (Force update of snapshots/releases").See this answer - here
Edit-As JF suggested ,the folder also contains the settings.xml
,A file that contains global settings for all maven executions,which you might not want to delete ,so you can just remove the repository folder,and reinstall your dependencies.
Unix/Mac OS X – ~/.m2/repository
Windows – C:\Users\{your-username}\.m2\repository
there is no node_modles equivalent for maven, there is a central local repository maintained .m2/repository folder in per system.
Maven first search for the dependency in that local repo if not found then goes to maven central.
So if you want to delete your local cashed repository you can just simply delete all the folders in .m2/repository folder.
Then maven will not found the dependencies locally and will go for outside which is maven central.
And target contains the build artifact for each project. And mvn clean install command will execute the two lifecycle phases clean and install. To run install, maven will run all the phases preceding install in the default maven lifecycle.
For further reference .
I'm still fairly new with Maven but I believe this will explain what your asking.
you can re-install the maven dependencies using the following command:
mvn dependency:purge-local-repository
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.