我已经为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>
一些事情:
artifactId
阶段,我的groupId
,version
和compile
应该是什么?Run Configurations
)吗?在Ant中有一个插件,可以让您查看build.xml
中定义的所有目标;我在Maven / m2e中看不到这样的模拟。答案 0 :(得分:1)
您不需要使用maven编译器的所有默认设置。如果你真的想要指定它,你可以这样做:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>