31

Getting this error while building the sprint boot application through eclipse.

[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.

but working fine if i build through command prompt. Attaching the pom.xml below.

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>
Noam Hacker
  • 4,671
  • 7
  • 34
  • 55
Sarun UK
  • 6,210
  • 7
  • 23
  • 48
  • 1
    How exactly do you start the build in Eclipse? Do you use any kind of wizard to run maven? If so, just put in the goals, not the mvn command itself. – dunni Aug 13 '16 at 07:51

11 Answers11

65

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

clean install

And skip all the tests.

21

Try without command mvn in the command line. Example:

From:

mvn clean install jetty:run

To:

clean install jetty:run
Angel Cuenca
  • 1,637
  • 6
  • 24
  • 46
7

Thanks for the reply. I was using "mvn clean install" in the maven build configuration. we no need to use "mvn" command if running through eclipse.

After buiding the application using the command "clean install" , I got one more error -
"No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?"

I followed this link:- No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

now application building is fine in eclipse.

Community
  • 1
  • 1
Sarun UK
  • 6,210
  • 7
  • 23
  • 48
5

I was getting the same error. I was using Intellij IDEA and I wanted to run Spring boot application. So, solution from my side is as follow.

Go to Run menu -> Run configuration -> Click on Add button from the left panel and select maven -> In parameters add this text -> spring-boot:run

Now press Ok and Run.

Urja Ramanandi
  • 199
  • 2
  • 5
1

You have to specify any one of the above phase to resolve the above error. In most of the situations, this would have occurred due to running the build from the eclipse environment.

instead of mvn clean package or mvn package you can try only package its work fine for me

pshailu
  • 11
  • 2
1

I too got the similar problem and I did like below..
Rt click the project, navigate to Run As --> click 6 Maven Clean and your build will be success..

Maven Clean

Build Success

Suresh
  • 1,491
  • 2
  • 22
  • 27
1

Sometimes this error comes because it's simply the wrong folder. :-(

It shall be the folder which contains the pom.xml.

Sven Döring
  • 3,927
  • 2
  • 14
  • 17
0

Create new Maven file with path as classpath and goal as class name

Sidharth Taneja
  • 548
  • 6
  • 7
0

This is unrelated to Eclipse but just linux shell. I got it because of running

mvn .

to compile jar package, instead of running

mvn

which fixes it.

VojtaK
  • 483
  • 4
  • 13
0

Better to check once mvn command you provided. My case I used

Command:

mvn mvn clean install

Error: [ERROR] Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goal

Corrected

mvn clean install
Radhakrishnan
  • 564
  • 4
  • 6
0

i dont know why when i run mvn command with powershell, it doesn't work but when i change to git bash and run the mvn it works, maybe powershell doesn't support

mvn spring-boot:run -Dspring-boot.run.arguments=--spring.application.instance_id=sergey

Long tran
  • 71
  • 1
  • 2