我已经安装了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
,groupId
和version
如果这是(标准)Mavencompile
阶段? - 这是启动 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/