I’m very new to Java Technology (Normally working on NodeJs and PHP but got a requirement to work with Spring Boot). I just want to run ‘Hello World’ on Spring MVC. But I’ve already spent a day. I don’t know why it’s super hard to just initialise a project.
I built a project from https://start.spring.io/
Project: Marven, LanguageL Java, Spring Boot:2.2.6, Packing: Java, Java: 11
Dependencies: Spring Web WEB, Thymeleaf and Spring Boot DevTools.
My mvn -version,
Maven home: /usr/local/Cellar/maven/3.6.0/libexec
Java version: 11.0.7, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-11.0.7.jdk/Contents/Home
Default locale: en_TH, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.5", arch: "x86_64", family: "mac"
My pom.xml,
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.myproject</groupId>
<artifactId>front-end-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>front-end-server</name>
<description>Front End Server</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
When I am trying to run it always return me error,
[INFO] Total time: 0.604 s
[INFO] Finished at: 2020-04-29T23:22:55+07:00
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "pom.xml" could not be activated because it does not exist.
[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.
[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
I also followed the http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException. but it’s not working.
I also tried the solution from https://crunchify.com/mavenmvn-clean-install-update-project-and-project-clean-options-in-eclipse-ide-to-fix-any-dependency-issue/
It’s not woking again.
Moreover, I also created a new project using Spring Tool Suite 4 (Hope the different result). It’s not working as well.
I normally take less than 30 mins to start a ‘hello world’ for new things. But for the Spring boot, It’s already taken me whole day.
Please help..
2
Answers
What command are you running? Something like “mvn clean install” should work.
Go into your project folder and run this command in the terminal.
After that right click on your main program and click on run as spring boot app. It should work.