Maven: Command to update repository after adding d

2019-01-08 03:17发布

I've added a new dependency to my POM.

Is there a simple command I can run to download this dependency to my repository?

4条回答
虎瘦雄心在
2楼-- · 2019-01-08 03:20

I know it is an old question now, but for users who are using Maven plugin with Eclipse under Windows, you have two options:

  1. If you got Maven installed as a standalone application:

    You can use the following command in the CMD under your project path:

    mvn eclipse:eclipse
    

    It will update your repository with all the missing jars, according to your dependencies in your pom.xml file.

  2. 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 new button to create a configuration of the selected type .Click on Browse workspace then select your project and in goals specify eclipse:eclipse

You can refer to how to run the command mvn eclipse:eclipse for further details.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-01-08 03:26

Right, click on the project. Go to Maven -> Update Project.

The dependencies will automatically be installed.

查看更多
我欲成王,谁敢阻挡
4楼-- · 2019-01-08 03:27

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.

查看更多
放我归山
5楼-- · 2019-01-08 03:29

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=...

查看更多
登录 后发表回答