未知的生命周期阶段“mvn”。您必须以<plugin-prefix>:<goal>或<plugin-group-id>格式指定有效的生命周期阶段或目标

时间:2016-08-13 07:44:06

标签: maven spring-boot

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

[错误]未知生命周期阶段“mvn”。您必须以以下格式指定有效的生命周期阶段或目标:或:[:]:。可用的生命周期阶段包括:验证,初始化,生成源,流程源,生成资源,流程资源,编译,流程类,生成测试源,流程测试源,生成测试资源,流程-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 ,后清理,前期网站,网站,后期网站,网站部署。 - &GT; [帮助1] [错误] [错误]要查看错误的完整堆栈跟踪,请使用-e开关重新运行Maven。

但如果我通过命令提示符构建工作正常。  附上下面的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>

9 个答案:

答案 0 :(得分:28)

If you are using debug configuration for maven, use the command

clean install

And skip all the tests.

答案 1 :(得分:6)

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

自:

mvn clean install jetty:run

要:

clean install jetty:run

答案 2 :(得分:4)

感谢您的回复。 我正在使用&#34; mvn clean install&#34;在maven构建配置中。 我们不需要使用&#34; mvn&#34;命令,如果通过eclipse运行。

使用命令&#34; clean install&#34;建立应用程序后。 ,我还有一个错误 -
&#34;此环境中未提供编译器。也许你是在运行JRE而不是JDK?&#34;

我关注此链接: - No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

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

答案 3 :(得分:2)

maven的调试配置为

全新安装

答案 4 :(得分:1)

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

而不是mvn clean package或mvn package,你可以尝试只为它打包工作

答案 5 :(得分:1)

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

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

答案 6 :(得分:0)

使用路径作为类路径和目标作为类名称创建新的Maven文件

答案 7 :(得分:0)

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

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

现在按“确定并运行”。

答案 8 :(得分:0)

我也遇到了类似的问题,下面我也做了。.
右键单击该项目,导航至“运行方式->单击6 Maven Clean,您的构建将成功。

Maven Clean

Build Success

相关问题