我正在 eclipse 中建立一个项目。 This projects builds successfully through command line(all mvn
commands like mvn package
, mvn compile
, mvn clean install
) work perfectly fine.在 STS 或 Eclipse 上设置此项目时。我看到一些依赖项没有被下载,即使它们存在于 pom.xml
中。但是,在 Maven 存储库中搜索它们并将 jar 下载到我的本地计算机,然后将它们添加到构建路径使其在 Eclipse 上运行。
我们是否需要对 eclipse 执行任何操作以确保它从存储库下载所有依赖项。
我的 POM :
<dependency>
<groupId>org.apache.bookkeeper</groupId>
<artifactId>bookkeeper-server-compat410</artifactId>
<version>4.1.0</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.apache.bookkeeper</groupId>
<artifactId>bookkeeper-server</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.bookkeeper</groupId>
<artifactId>bookkeeper-server-compat420</artifactId>
<version>4.2.0</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.apache.bookkeeper</groupId>
<artifactId>bookkeeper-server</artifactId>
</exclusion>
</exclusions>
</dependency>
这两个工件都没有为 eclipse 下载,并且找到了 jars http://mvnrepository.com/artifact/org.apache.bookkeeper/bookkeeper-server-compat410/4.1.0 和 http://mvnrepository.com/artifact/org。 apache.bookkeeper/bookkeeper-server-compat420/4.2.0 不存在于 MavenDependencies 的文件夹中,随后在 Eclipse 中出现错误。
但是,手动将它们添加到构建路径会创建一个新文件夹(参考库)并解决 Eclipse Errors 。为什么Eclipse没有自己从maven仓库下载导入这些依赖??是 Eclipse 中的错误还是我这边的一些问题。请帮忙。
原文由 Ankur Garg 发布,翻译遵循 CC BY-SA 4.0 许可协议
设置正确的代理:
只是删除
并尝试更新 Maven。
[大多数时候这个解决方案会起作用]