【问题标题】:Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>未知的生命周期阶段“mvn”。您必须以 <plugin-prefix>:<goal> 或 <plugin-group-id> 格式指定有效的生命周期阶段或目标
【发布时间】:2016-12-20 04:56:40
【问题描述】:

通过 Eclipse 构建 sprint 启动应用程序时出现此错误。

[ERROR] Unknown lifecycle phase "mvn". 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.

但如果我通过命令提示符构建,则工作正常。 下面附上pom.xml。

Pom.xml

<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.sarun</groupId>
    <artifactId>SpringAngular</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name> SpringDataRestAngular</name>
    <description>Spring + AngularJS </description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.1.3.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>
        <!-- <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> -->

        <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.3-1100-jdbc41</version>
        </dependency>

    </dependencies>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <start-class>com.programmingfree.springservice.Application</start-class>
        <java.version>1.7</java.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

【问题讨论】:

  • 究竟如何在 Eclipse 中开始构建?您是否使用任何类型的向导来运行 Maven?如果是这样,只需输入目标,而不是 mvn 命令本身。

标签: maven spring-boot


【解决方案1】:

如果你正在使用 maven 的调试配置,请使用命令

clean install

并跳过所有测试。

【讨论】:

    【解决方案2】:

    在命令行中尝试不使用命令mvn。示例:

    发件人:

    mvn clean install jetty:run
    

    收件人:

    clean install jetty:run
    

    【讨论】:

      【解决方案3】:

      感谢您的回复。 我在 Maven 构建配置中使用了“mvn clean install”。 如果通过eclipse运行,我们不需要使用“mvn”命令。

      使用“干净安装”命令构建应用程序后,我又遇到了一个错误 -
      “在这个环境中没有提供编译器。也许你是在 JRE 而不是 JDK 上运行的?”

      我点击了这个链接:- No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

      现在在 Eclipse 中构建应用程序很好。

      【讨论】:

        【解决方案4】:

        我遇到了同样的错误。我正在使用 Intellij IDEA,我想运行 Spring Boot 应用程序。所以,我这边的解决方案如下。

        转到运行菜单->运行配置->单击左侧面板中的添加按钮并选择maven->在参数中添加此文本->spring-boot:run

        现在按确定并运行。

        【讨论】:

          【解决方案5】:

          您必须指定上述任一阶段才能解决上述错误。在大多数情况下,这可能是由于从 eclipse 环境中运行构建而发生的。

          代替 mvn clean package 或 mvn package 你可以尝试只打包它对我的工作正常

          【讨论】:

            【解决方案6】:

            我也遇到了类似的问题,我确实喜欢下面..
            Rt 单击项目,导航到 Run As --> 单击 6 Maven Clean,您的构建将成功..

            【讨论】:

              【解决方案7】:

              有时会出现此错误,因为它只是错误的文件夹。 :-(

              应该是包含pom.xml的文件夹。

              【讨论】:

              • 你能说得更具体点吗?
              【解决方案8】:

              创建新的 Maven 文件,路径为类路径,目标为类名

              【讨论】:

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