【问题标题】:Unknown lifecycle phase "build". You must specify a valid lifecycle phase or a goal in the format未知的生命周期阶段“构建”。您必须在格式中指定有效的生命周期阶段或目标
【发布时间】:2022-01-02 23:36:15
【问题描述】:

团队,

在我的 pom 文件中出现以下错误。未知的生命周期阶段“构建”。您必须在格式中指定有效的生命周期阶段或目标。我浏览了提供的 URL,但仍然收到错误消息。 MVN 版本 3.2.1,Java 版本:1.7.0_51 任何帮助将不胜感激

POM 看起来像:

<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.organization.dramer</groupId>
<artifactId>sTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>sTest</name>
<description>test automation framework created using Java, testNG,
selenium</description>


  <properties>
  <suiteXmlFile>src/main/resources/testng.xml</suiteXmlFile>
  <skipTests>false</skipTests>
  </properties>

  <dependencies>
    <dependency>
        <groupId>org.apache.maven.plugin-tools</groupId>
        <artifactId>maven-plugin-annotations</artifactId>
        <version>3.2</version>
        <scope>provided</scope>
    </dependency>

  <dependency>
  <groupId>org.testng</groupId>
  <artifactId>testng</artifactId>
  <version>6.8</version>
  <scope>test</scope>
  </dependency>

  <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-firefox-driver</artifactId>
        <version>2.53.0</version>
    </dependency>

    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-chrome-driver</artifactId>
    <version>2.44.0</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>htmlunit-driver</artifactId>
        <version>2.20</version>
    </dependency>  

    <dependency>
        <groupId>net.sourceforge.jexcelapi</groupId>
        <artifactId>jxl</artifactId>
        <version>2.6.12</version>
    </dependency>

      </dependencies>

  <build>

  <plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
            <source>1.6</source>
            <target>1.6</target>
        </configuration>
    </plugin>

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.6</version>
        <configuration>
            <suiteXmlFiles>
                <suiteXmlFile>${suiteXmlFile)</suiteXmlFile>
            </suiteXmlFiles>    
            <testFailureIgnore>true</testFailureIgnore>
        </configuration>
    </plugin>
  </plugins>




  </build>




</project>

【问题讨论】:

  • 你在运行什么命令?你的pom.xml 是什么样的?
  • mvn clean,然后 mvn build
  • build 不是 maven 的标准阶段。您的意思是使用mvn compile(构建/编译项目)还是mvn test(编译并运行所有单元测试)?
  • mvn compile 抛出各种错误有关错误和可能的解决方案的更多信息,请阅读以下文章:[ERROR] [Help 1] cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

标签: java maven


【解决方案1】:

Maven 没有build 目标(Maven 术语中的阶段),您可能想要的是compile、test 或install,具体取决于您想要实现的目标。

请通读Introduction to the Build Lifecycle,详细了解 Maven 生命周期的工作原理以及每个步骤的作用。

【讨论】:

  • mvn 测试效果很好,但使用黄瓜标签定义失败
【解决方案2】:

maven 没有任何build 目标,这意味着如果你运行mvn build 命令。 此命令在 Maven 生命周期中不存在。

  • 您必须运行 mvn pacage 才能运行该项目
  • mvn compile 编译
  • mvn test 用于测试
  • mvn install 安装

【讨论】:

    猜你喜欢
    • 2017-10-06
    • 2016-12-20
    • 2020-10-19
    • 2021-05-01
    • 2017-11-10
    • 2013-05-05
    • 2021-10-18
    • 2021-02-02
    • 2021-01-25
    相关资源
    最近更新 更多