使用嵌入在Eclipse中的Maven安装依赖项

使用嵌入在Eclipse中的Maven安装依赖项,eclipse,maven,Eclipse,Maven,我试图添加log4j作为Maven依赖项。所以我把它添加到pom.xml中 <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.15</version> </dependency> 请让我知道我是否走在正确的道路上,以及如何最好地获得log4j依赖项。提前感谢您的帮

我试图添加log4j作为Maven依赖项。所以我把它添加到pom.xml中

<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.15</version>
</dependency>
请让我知道我是否走在正确的道路上,以及如何最好地获得log4j依赖项。提前感谢您的帮助

更新 在检查Preferences>Maven>User Settings之后,我发现被引用的Settings.xml文件不存在。我单击“更新设置”,出现以下错误:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building ############# 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.522s
[INFO] Finished at: Wed Nov 27 12:13:11 CST 2013
[INFO] Final Memory: 6M/122M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project #############: Could not resolve dependencies for project #############:#############:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: javax.jms:jms:jar:1.1, com.sun.jdmk:jmxtools:jar:1.2.1, com.sun.jmx:jmxri:jar:1.2.1: Could not transfer artifact javax.jms:jms:jar:1.1 from/to java.net (https://maven-repository.dev.java.net/nonav/repository): No connector available to access repository java.net (https://maven-repository.dev.java.net/nonav/repository) of type legacy using the available factories AsyncRepositoryConnectorFactory, WagonRepositoryConnectorFactory -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
ArtifactTransferException: Could not transfer artifact com.sun.jdmk:jmxtools:jar:1.2.1 from/to java.net (https://maven-repository.dev.java.net/nonav/repository): No connector available to access repository java.net (https://maven-repository.dev.java.net/nonav/repository) of type legacy using the available factories AsyncRepositoryConnectorFactory, WagonRepositoryConnectorFactory
更新2

看起来我的问题是因为Maven 3(开普勒附带)试图访问Maven 2存储库,并且存在兼容性问题。我还没有弄清楚如何重定向到适当的存储库。

您可以右键单击项目,然后Maven>更新快照。(请确保选中“快照强制更新”复选框。这应该会起作用。

我将版本从1.2.15更改为1.2.17,并且它起作用(1.2.16也起作用)。我没有看到列出的任何依赖项“”与我在1.2.15中所做的一样,在“已解决的依赖项”框架中列出。我不完全理解为什么这样做有效,但它对我有效。

我有选项Maven>Update Project。我运行了它,但它没有帮助。它没有将日志打印到控制台…当您执行Maven>Update Snapshot时,它将从C:/Users//更新存储库。mac ~/.m2中Windows中的m2/repository文件夹,因此本地存储库已更新,您在控制台中看不到任何更新。为了安全性和IDE独立性,我强烈建议您在计算机中安装Maven并通过它运行构建,而不是使用嵌入式的。为了安全性,我想我可能已经完成了对曼恩是一个强大的工具,但正如本叔叔所说:“强大的力量带来巨大的责任”。你不能部分地使用它,你必须理解它并接受它的问题。