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

时间:2013-11-27 18:36:53

标签: eclipse maven

我正在尝试将log4j添加为Maven依赖项。所以我把它添加到pom.xml

<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.15</version>
</dependency>

现在我有一条警告消息,我遗漏了6件工件(log4j所依赖的罐子)。如以下网站Maven Repository - log4j所述。

我的目标是让Maven为我安装6个依赖项。我有嵌入式Maven的Eclipse Kepler,所以我无法运行&#34; mvn install&#34;。我从这个stackoverflow回答Run Maven Install in Eclipse看到我可以右键单击该项目并运行为&gt; Maven安装。但是我收到以下错误:

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

如果我走在正确的道路上,请告诉我以及如何最好地获取log4j依赖项。提前感谢您的帮助。

更新 检查首选项&gt; Maven&gt;用户设置,我发现正在引用的settings.xml文件不存在。我点击了&#34;更新设置&#34;我收到以下错误:

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(随Kepler一起提供)试图访问Maven 2存储库并存在兼容性问题。我还没弄明白如何重定向到适当的存储库。

2 个答案:

答案 0 :(得分:2)

我将版本从1.2.15更改为1.2.17并且它有效(1.2.16也可以)。我没有看到任何列出的依赖项&#34; here&#34;在Resolved Dependencies框架中列出,就像我在1.2.15中所做的那样。我没有完全理解为什么这样有效,但它对我有用。

答案 1 :(得分:0)

您可以右键单击您的项目,然后Maven&gt;更新快照。 (确保您选中“强制更新快照”复选框。这应该有效。