pom.xml shows multiple errors on including log4j dependency
我刚刚创建了一个新的Java项目,并将其配置为Eclipse中的" Maven项目"。 pom.xml文件是自动生成的。现在没有错误。我已经在自动生成的pom.xml文件中添加了log4j依赖关系,它显示了pom.xml文件下方显示的一些错误。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <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> Log4JPactice</artifactId> <version>0.0.1-SNAPSHOT</version> <build> <sourceDirectory>src</sourceDirectory> <plugins> <plugin> 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> log4j</artifactId> <version>1.2.15</version> </dependency> </dependencies> </project> |
错误:
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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
对这个错误有任何想法吗?
更新:
从命令行运行
1 2 3 4 5 6 7 8 | 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] |
您可以排除那些依赖项,因为您可能不需要它们
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <dependency> <groupId>log4j</groupId> log4j</artifactId> <version>1.2.15</version> <exclusions> <exclusion> <groupId>com.sun.jdmk</groupId> jmxtools</artifactId> </exclusion> <exclusion> <groupId>com.sun.jmx</groupId> jmxri</artifactId> </exclusion> <exclusion> <groupId>javax.jms</groupId> jms</artifactId> </exclusion> </exclusions> </dependency> |
我用了它,而且奏效了
1 2 3 4 5 6 | <dependencies> <dependency> <groupId>log4j</groupId> log4j</artifactId> <version>1.2.17</version> </dependency> |
但是它不能与版本1.2.15一起使用可能是版本问题
我的解决方法是:
1 2 3 4 5 6 7 | <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> |
一个不错的是1.2.15具有中央存储库中缺少的依赖项。 jmxri:jar看起来甚至不存在或已从repository.jboss.org中移出。只需更新到1.2.16或更高版本即可。
下面是Eclipse STS的评论
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.
原始错误
Could not transfer artifact com.sun.jmx:jmxri:jar:1.2.1 from/to java.net (https://maven-repository.dev.java.net/nonav/repository):"