Maven: Command to Update Repository After Adding Dependency to Pom
I've Added a New Dependency to My Pom. Is There a Simple Command I Can Run to Download This Dependency to My Repository? 1 5 Answers If You Want to Only...
I've added a new dependency to my POM.
Is there a simple command I can run to download this dependency to my repository?
5 Answers
If you want to only download dependencies without doing anything else, then it's:
mvn dependency:resolve
Or to download a single dependency:
mvn dependency:get -Dartifact=groupId:artifactId:version
If you need to download from a specific repository, you can specify that with -DrepoUrl=...
mvn install (or mvn package) will always work.
You can use mvn compile to download compile time dependencies or mvn test for compile time and test dependencies but I prefer something that always works.
I know it is an old question now, but for users who are using Maven plugin with Eclipse under Windows, you have two options:
If you got Maven installed as a standalone application:
You can use the following command in the
CMDunder your project path:mvn eclipse:eclipseIt will update your repository with all the missing jars, according to your dependencies in your
pom.xmlfile.If you haven't got Maven installed as a standalone application you can follow these steps on your eclipse:
Right click on the
project->Run As-- >Run configurations.Then select
mavenBuild.Then click
newbutton to create a configuration of the selected type .Click on Browse workspace then select your project and in goals specifyeclipse:eclipse
You can refer to how to run the command mvn eclipse:eclipse for further details.
Pay attention to your dependency scope I was having the issue where when I invoke clean compile via Intellij, the pom would get downloaded, but the jar would not. There was a xxx.jar.lastUpdated file created. Then realized that the dependency scope was test, but I was triggering the compile. I deleted the repos, and triggered the mvn test, and issue was resolved.
Right, click on the project. Go to Maven -> Update Project.
The dependencies will automatically be installed.