java - M2Eclipse (M2E) 构建错误

标签 java eclipse maven build m2e

我已经安装了m2e Eclipse 的插件并使用它创建了一个简单的原型(prototype)。我编写了一个小型测试驱动程序,并尝试构建该项目(通过 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

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

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

一些事情:

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

最佳答案

您不需要放置任何内容,因为您正在使用 Maven 编译器的所有默认设置。如果你确实想指定它,你可以这样做:

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

关于java - M2Eclipse (M2E) 构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9236434/

相关文章:

java - 在多个项目中管理 Spring Boot 父 POM 版本

java - 将 jsp 方法拆分为多个 scriplet,以在其间包含 html 代码

java - 如何在 Spring 框架中对数据提供者层进行单元测试(插入)?

java - 为什么 "else if"语句的第一个条件总是假?

c - Eclipse 中包含路径问题 : probably Indexer

java - 为 Mac OS X 安装 Java JDK 7 后 - mvn -version 仍然显示 java 版本 1.6.0_31

java - 如何将日期字符串解析为日期?

java - 无法在 Apple MacPro 上启动新的 Android 应用程序

java - 如何在 Java Eclipse 中访问数据字段

java - 如何使用 Java 和 Maven 实现 Microsoft Graph API