【问题标题】:M2Eclipse (M2E) build errorsM2Eclipse (M2E) 构建错误
【发布时间】:2012-03-03 10:23:41
【问题描述】:

我已经为 Eclipse 安装了m2e 插件并用它来创建一个简单的原型。我编写了一个小型测试驱动程序并尝试构建项目(通过 Maven)并将我的 Java 源代码编译到类文件中。

我转到Run >> Run Configurations 并创建一个New Maven Build。我将其命名并将其基目录设置为我的项目根目录。

当我尝试选择 Goals 时,它看不到任何内容,因此我无法添加/指定任何内容。我单击Run 按钮。这是我的控制台输出:

[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project org.me:myproject:0.0.1-SNAPSHOT (C:\Users\me\workbench\eclipse\workspace\MyProject\pom.xml) has 3 errors
[ERROR]     'build.plugins.plugin.artifactId' is missing. @ line 145, column 17
[ERROR]     'build.plugins.plugin.groupId' is missing. @ line 144, column 14
[ERROR]     'build.plugins.plugin.version' for : must be a valid version but is ''. @ line 146, column 14
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

我的 pom.xml 中的 <build> 标签是:

<build>
    <plugins>
        <plugin>
            <groupId></groupId>
            <artifactId></artifactId>
            <version></version>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>compiler:compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

一些事情:

  • 如果这是(标准)Maven compile 阶段,我的 artifactIdgroupIdversion 应该是什么?
  • 这是启动 Maven 构建(通过Run Configurations)的正确方法吗?在 Ant 中,有一个插件可以让您查看在 build.xml 中定义的所有目标;我在 Maven/m2e 中看不到这样的类似物。
  • 为什么像 compile 这样简单的东西需要插件?人们会认为这将是任何构建工具的标准部分。

【问题讨论】:

    标签: java eclipse maven build m2e


    【解决方案1】:

    您无需添加任何内容,因为您使用的是 maven 编译器的所有默认设置。如果你真的想指定它,你可以这样做:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
    </plugin>
    

    【讨论】:

    • 谢谢!重新检查 pom.xml 后,我在上面粘贴的 &lt;execution&gt; 元素上看到一个以红色突出显示的错误(由 Eclipse)。错误内容为:生命周期配置未涵盖插件执行:org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compiler:compile(执行:默认,阶段:编译)。这和你在说什么有关系吗?如果有,有什么补救措施?
    • 另外,关于我开始构建的方式,这是从 Eclipse 内部(通过运行配置)调用 Maven/m2e 的标准方式吗?
    • 你想做什么? Maven 帮助您构建和打包源代码。编译只是这一过程的一个步骤。此外,这一步是由 Eclipse 中的 Eclipse Java 编译器完成的。您可以考虑向 Maven 用户邮件列表发送更详细的问题以获得更多帮助。
    • 我认为我的问题令人困惑,因为我是一个“Maven 新手”,并且可能没有提出正确的问题。我想做的就是在 Eclipse 中编译我的项目,但是使用 Maven(通过 m2e 插件)。你能告诉我我的&lt;build&gt; 标签(和/或运行配置)需要是什么样子,并告诉我为了实现这一目标我需要采取哪些步骤?感谢您对我的耐心!
    • 我阅读了 Maven 文档!它没有任何地方显示我遇到的错误(关于 maven-compiler-plugin)。我花了一整天的时间阅读文档,并不是因为懒惰才写这个问题!!!
    猜你喜欢
    • 2012-02-08
    • 2012-02-08
    • 1970-01-01
    • 2011-04-02
    • 2014-07-16
    • 1970-01-01
    • 1970-01-01
    • 2011-12-09
    • 2011-05-31
    相关资源
    最近更新 更多