Maven:将本地log4j jar设置为依赖项时出错

时间:2013-11-17 11:32:18

标签: maven jar log4j pom.xml

由于某些技术原因,我必须将log4j作为本地jar包含在pom文件中。我试过了:

<dependency>
  <groupId>log4j</groupId>
  <artifactId>apache-log4j-extras</artifactId>
  <scope>system</scope>
  <systemPath>path_to_jar/apache-log4j-extras-1.1.jar</systemPath>
</dependency>

有没有:

  <version>1.1</version>

无论哪种方式,我都会得到神秘的消息Failed to validate POM for project,而没有参考具体的失败原因。当从maven存储库中获取log4j时,这很有效。

[INFO] Trace
org.apache.maven.reactor.MavenExecutionException: Failed to validate POM for project ... at ...hudson_checkout/vespa_qa/pom_local.xml
    at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:404)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:272)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.project.InvalidProjectModelException: Failed to validate POM for project ... at /....xml
    at org.apache.maven.project.DefaultMavenProjectBuilder.processProjectLogic(DefaultMavenProjectBuilder.java:1077)
    at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(DefaultMavenProjectBuilder.java:880)
    at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.java:508)
    at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:200)
    at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:604)
    at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:487)
    at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:391)
    ... 12 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second

jar位于指定的文件夹中,具有读取权限。知道这种依赖有什么问题吗?

1 个答案:

答案 0 :(得分:0)

executed maven with "-X",得到了更有用的信息:

[0]  'dependencies.dependency.version' is missing for log4j:apache-log4j-extras:jar

所以我再次添加了该版本。该项目仍然失败,带有奇怪的错误消息。我进一步搜索,发现从系统路径获取og4j的常用方法需要tis组ID:

<groupId>org.apache.log4j</groupId>

而不是:

<groupId>log4j</groupId>