eclipse pom.xml 显示包含 log4j 依赖项的多个错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20611991/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 21:24:01  来源:igfitidea点击:

pom.xml shows multiple errors on including log4j dependency

eclipsemavenlogging

提问by PhantomReference

I have just created a new java project and configured it as a 'maven project' in eclipse. pom.xml file is autogenerated. It has no error at this point. I've added the log4j dependency in the auto generated pom.xml file and it shows a few errors that are shown below the pom.xml file.

我刚刚创建了一个新的 java 项目,并在 eclipse 中将其配置为“maven 项目”。pom.xml 文件是自动生成的。在这一点上它没有错误。我在自动生成的 pom.xml 文件中添加了 log4j 依赖项,它显示了 pom.xml 文件下方显示的一些错误。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Log4JPactice</groupId>
<artifactId>Log4JPactice</artifactId>
<version>0.0.1-SNAPSHOT</version>

    <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
    </build>

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

Error:

错误:

Multiple annotations found at this line:
    - Missing artifact javax.jms:jms:jar:1.1
    - ArtifactTransferException: Failure to transfer com.sun.jdmk:jmxtools:jar:1.2.1 from https://maven-repository.dev.java.net/nonav/repository was cached in the local repository, resolution will not be reattempted until the update interval of java.net has elapsed or 
     updates are forced. Original error: 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
    - ArtifactTransferException: Failure to transfer javax.jms:jms:jar:1.1 from https://maven-repository.dev.java.net/nonav/repository was cached in the local repository, resolution will not be reattempted until the update interval of java.net has elapsed or updates are 
     forced. Original error: 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
    - ArtifactTransferException: Failure to transfer com.sun.jmx:jmxri:jar:1.2.1 from https://maven-repository.dev.java.net/nonav/repository was cached in the local repository, resolution will not be reattempted until the update interval of java.net has elapsed or updates 
     are forced. Original error: Could not transfer artifact com.sun.jmx:jmxri: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
    - Missing artifact com.sun.jdmk:jmxtools:jar:1.2.1
    - Missing artifact com.sun.jmx:jmxri:jar:1.2.1

Eclipse used: Eclipse Juno

使用的 Eclipse:Eclipse Juno

Any idea about this error?

对这个错误有什么想法吗?

Update: On running mvn installfrom the command line I get the following error:

更新:mvn install从命令行运行时出现以下错误:

    Failed to execute goal on project Log4JPactice: Could not resolve dependencies for project Failed to execute goal on project Log4JPactice: Could not resolve dependencies 
for project Log4JPactice:Log4JPactice: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]

回答by mavroprovato

You can exclude those dependencies, as you probably don't need them

您可以排除这些依赖项,因为您可能不需要它们

<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.15</version>
    <exclusions>
        <exclusion>
            <groupId>com.sun.jdmk</groupId>
            <artifactId>jmxtools</artifactId>
        </exclusion>
        <exclusion>
            <groupId>com.sun.jmx</groupId>
            <artifactId>jmxri</artifactId>
        </exclusion>
        <exclusion>
            <groupId>javax.jms</groupId>
            <artifactId>jms</artifactId>
        </exclusion>
    </exclusions>
</dependency>

回答by JustTry

I used this and it worked

我用过这个,它奏效了

<dependencies>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>

But its not working with version 1.2.15 may be a version issue

但它不适用于 1.2.15 版本可能是版本问题

回答by zond

my solution is:

我的解决方案是:

<repositories>
    <repository>
        <id>repository.jboss.org-public</id>
        <name>JBoss.org Maven repository</name>
        <url>https://repository.jboss.org/nexus/content/groups/public</url>
    </repository>
</repositories>

回答by Khaled Majid

Good one yes 1.2.15 has dependencies which are missing from central repository.e.g. jmxri:jar Looks like it even does not exist or has been moved from repository.jboss.org. Just update to 1.2.16 or higher.

好的,是的 1.2.15 具有中央存储库中缺少的依赖项。例如 jmxri:jar 看起来它甚至不存在或已从 repository.jboss.org 移动。只需更新到 1.2.16 或更高版本。

Below are comments from eclipse STS

以下是来自 eclipse STS 的评论

Failure to transfer com.sun.jmx:jmxri:jar:1.2.1 from https://maven-repository.dev.java.net/nonav/repositorywas cached in the local repository, resolution will not be reattempted until the update interval of java.net has elapsed or updates are forced.

https://maven-repository.dev.java.net/nonav/repository传输 com.sun.jmx:jmxri:jar:1.2.1 失败被缓存在本地存储库中,直到更新间隔才会重新尝试解析java.net 已过期或强制更新。

Original error

原始错误

Could not transfer artifact com.sun.jmx:jmxri:jar:1.2.1 from/to java.net (https://maven-repository.dev.java.net/nonav/repository):"

无法从/向 java.net ( https://maven-repository.dev.java.net/nonav/repository)传输工件 com.sun.jmx:jmxri:jar:1.2.1 :"