我向POM添加了一个新的依赖项。

我是否可以运行一个简单的命令将这个依赖项下载到我的存储库中?


当前回答

我知道这是一个老问题了,但是对于那些在Windows下使用Maven插件和Eclipse的用户来说,你有两个选择:

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

详细信息请参见如何运行mvn eclipse:eclipse命令。

其他回答

如果你只想下载依赖项而不做任何其他事情,那么它是:

mvn dependency:resolve

或者下载单个依赖项:

mvn dependency:get -Dartifact=groupId:artifactId:version

如果你需要从一个特定的存储库中下载,你可以使用-DrepoUrl=…

MVN安装(或MVN包)将始终工作。

您可以使用mvn compile来下载编译时依赖项或mvn test来下载编译时和测试依赖项,但我更喜欢总是工作的东西。

注意您的依赖范围 我有一个问题,当我通过Intellij调用清洁编译时,pom会被下载,但jar不会。创建了一个xxx.jar.lastUpdated文件。然后意识到依赖关系范围是test,但我正在触发编译。我删除了回购,并触发了mvn测试,问题解决了。

我知道这是一个老问题了,但是对于那些在Windows下使用Maven插件和Eclipse的用户来说,你有两个选择:

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

详细信息请参见如何运行mvn eclipse:eclipse命令。

对,点击项目。 进入Maven ->更新项目。

依赖项将自动安装。