Maven eclipse包装“pom”无法正常工作

时间:2015-08-12 15:50:48

标签: java eclipse maven

我正在使用Eclipse Mars(4.5)和Maven 3.3.3。

最近,我对Java 8(SE)项目进行了Maven更新,突然之间,Eclipse不希望我的 pom.xml 中的<packaging>jar</packaging>成为有效,但希望我将包装更改为 pom 。为什么我不能把它留给 jar

此外,在概述中,包装选项已禁用。

当从控制台运行maven时(使用jar包装),这就是我得到的:

[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Child module C:\Users\Me\workspace\MyProject\? of C:\Users\Me\workspace\MyProject\pom.xml does not exist @
[ERROR] 'packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as packaging. @ line 8, column 13
 @
[ERROR] The build could not read 1 project -> [Help 1]
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[ERROR] Child module C:\Users\Me\workspace\MyProject\? of C:\Users\Me\workspace\MyProject\pom.xml does not exist @
[ERROR] 'packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as packaging. @ line 8, column 13

        at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:422)
        at org.apache.maven.graph.DefaultGraphBuilder.collectProjects(DefaultGraphBuilder.java:419)
        at org.apache.maven.graph.DefaultGraphBuilder.getProjectsForMavenReactor(DefaultGraphBuilder.java:410)
        at org.apache.maven.graph.DefaultGraphBuilder.build(DefaultGraphBuilder.java:83)
        at org.apache.maven.DefaultMaven.buildGraph(DefaultMaven.java:491)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:219)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[ERROR]
[ERROR]   The project MyProject:model:0.2 (C:\Users\Me\workspace\MyProject\pom.xml) has 2 errors
[ERROR]     Child module C:\Users\Me\workspace\MyProject\? of C:\Users\Me\workspace\MyProject\pom.xml does not exist
[ERROR]     'packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as packaging. @ line 8, column 13

有人能帮助我吗?至少在重新启用罐子包装。 感谢。

编辑:确实,我的 pom.xml 添加了一些新行(我不知道为什么或如何):

<modules>
    <module>?</module>
</modules>

这就是造成这个问题的原因。删除它会让问题消失,谢谢!

2 个答案:

答案 0 :(得分:4)

因为如果你的pom声明模块它是一个“聚合器POM” - 聚合器模块必须是pom。这就是您在日志中收到以下错误的原因:

[ERROR] 'packaging' with value 'jar' is invalid. 
    Aggregator projects require 'pom' as packaging. @ line 8, column 13

当您从pom中删除所有jar声明后,您可以返回<module>

请参阅multi-module projects的文档。

答案 1 :(得分:0)

以某种方式重新启动Eclipse之后,另一个“模块”带有“?”被添加到我的pom文件中。搜索并删除它。它将解决问题。

Module with ?

<module>?</module>