【发布时间】:2013-12-13 13:31:29
【问题描述】:
我正在尝试将 log4j 添加为 Maven 依赖项。所以我将它添加到 pom.xml 中
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
</dependency>
现在我收到一条警告消息,提示我缺少 6 个工件(log4j 依赖的 jar)。如以下网站Maven Repository - log4j所述。
我的目标是让 Maven 为我安装 6 个依赖项。我有带有嵌入式 Maven 的 Eclipse Kepler,所以我无法运行“mvn install”。我从这个 stackoverflow 答案Run Maven Install in Eclipse 中看到,我可以右键单击该项目并运行为 > 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 依赖项。提前感谢您的帮助。
更新 检查 Preferences > Maven > User Settings 后,我发现所引用的 settings.xml 文件不存在。我点击“更新设置”,出现以下错误:
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 存储库并遇到兼容性问题的结果。我还没有弄清楚如何重定向到适当的存储库。
【问题讨论】:
-
为了理智和 IDE 的独立性,我强烈建议你在你的机器上安装 Maven 并通过它运行构建,而不是使用嵌入式的。
-
为了理智,我想我可能已经完成了对 Maven 的实验。
-
Manen 是一个强大的工具,但正如 Ben 叔叔所说:“权力越大,责任越大”。你不能部分使用它,你必须理解它并接受它的问题。