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

时间:2013-12-16 13:20:57

标签: eclipse maven logging

我刚创建了一个新的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>

错误:

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:Eclipse Juno

有关此错误的任何想法?

更新: 在从命令行运行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]

4 个答案:

答案 0 :(得分:16)

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

<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>

答案 1 :(得分:3)

我用过它并且有效

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

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

答案 2 :(得分:1)

我的解决方案是:

<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>

答案 3 :(得分:-1)

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

以下是eclipse STS的评论

  

无法从https://maven-repository.dev.java.net/nonav/repository转移com.sun.jmx:jmxri:jar:1.2.1缓存在本地存储库中,在java.net的更新间隔过去或更新后,将不再重新尝试解析被迫的。

原始错误

  

无法将工件com.sun.jmx:jmxri:jar:1.2.1从/转移到java.net(https://maven-repository.dev.java.net/nonav/repository):“

相关问题