使用Maven和Eclipse运行Tomcat - 未知的生命周期阶段

Ant*_*ony 8 eclipse maven tomcat7

我正在使用Eclipse Helios,Tomcat Server 7.我使用Maven构建了我的项目.当我尝试构建我的项目时,我在Eclipse中遇到以下错误.

 [INFO] Scanning for projects...
 [INFO]                                                                         
 [INFO] ------------------------------------------------------------------------
 [INFO] Building encore Maven Webapp 0.0.1-SNAPSHOT
 [INFO] ------------------------------------------------------------------------
 [INFO] ------------------------------------------------------------------------
 [INFO] BUILD FAILURE
 [INFO] ------------------------------------------------------------------------
 [INFO] Total time: 0.095s
 [INFO] Finished at: Tue Nov 06 18:17:55 IST 2012
 [INFO] Final Memory: 2M/36M
 [INFO] ------------------------------------------------------------------------
 [ERROR] Unknown lifecycle phase "build". You must specify a valid lifecycle phase or    a    goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
 [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/LifecyclePhaseNotFoundException
Run Code Online (Sandbox Code Playgroud)

请告诉我代码中的错误,并指出正确的方向.我需要尽快弄明白.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.encore</groupId>
<artifactId>encore</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>encore Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
  <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
   </dependency>
   <dependency>
    <groupId>org.codehaus.mojo</groupId>
  <artifactId>tomcat-maven-plugin</artifactId>
  <version>1.1</version>      
</dependency>
 <dependency>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-eclipse-plugin</artifactId>
  <version>2.9</version>     
</dependency>
</dependencies>

<build>
<finalName>encore</finalName>   
<plugins>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>tomcat-maven-plugin</artifactId>
         <version>2.9</version>  
        <configuration>
                 <server>mytomcatserver</server>
                 <path>/encore</path>
                 <url>http://localhost:8080</url>
                 <username>admin</username>
                 <password>admin</password>
        </configuration>
    </plugin>
</plugins>
</build>
 </project>
Run Code Online (Sandbox Code Playgroud)

这是我的pom.xml.我正在尝试以eclipse运行我的应用程序作为Run as-> mvn build.

Dun*_*nes 12

听起来你在尝试使用Eclipse构建时不小心设置了错误的目标.编辑你的Maven"Run as .."设置如下:

在此输入图像描述

请注意clean install,它将运行Maven命令来清理构建并执行完整构建并安装到本地存储库中.


Aar*_*lla 7

尝试mvn install而不是mvn build.build不是Maven的有效选项.您可以在上面的错误消息中找到有效选项的列表.

如果您只想编译源代码,请尝试,mvn compile但如果pom.xml项目中有多个文件,通常会产生错误的结果.