0

我已经m2e为 Eclipse 安装了插件并用它来创建一个简单的原型。我编写了一个小型测试驱动程序并尝试构建项目(通过 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阶段artifactId,我应该怎么做groupIdversioncompile
  • Is this the correct way to launch a Maven build (through Run Configurations)? In Ant there is a plugin that lets you see all of the targets defined in your build.xml; I see no such analog in Maven/m2e.
  • Why does something as simple as compile require plugins? One would think this would be a standard part of any build tool.
4

1 回答 1

1

You don't need to put anything as you are using all the defaults settings of the maven compiler. If you really want to specify it you can do it this way:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
</plugin>
于 2012-02-10T23:50:22.967 回答