How to run a maven project in eclipse?
Maven provides excellent support in the Eclipse IDE. With the help of the Eclipse GUI-based interface, we can easily create Maven projects and build, deploy, and operate them.
- Making a small Maven project, building it, and running it
- We use Maven to create a Java Web Project in Eclipse.
- Maven is used to converting a basic Java project
1. Creating a Simple Maven Project in Eclipse

The new project wizard will open when you select File > New > Project. Click the "Next" button after selecting "Maven Project" as in the image below.
We can define the project location and include it in any working set on the next screen. We won't change it in any way. Another choice is to skip archetype selection and make a basic project instead. However, to develop the template project, we will employ the archetype.

We must choose the project archetype on the next screen. This is the essential step in the project's development. We need a basic maven JAR-based application. Therefore, we will select the "maven-archetype-quickstart" artifact to start the project.
We must enter the project's groupId, artifactId, and base package on the following screen.
The popup wizard window will close after you click the Finish button, and the project will be created. It will appear in the project explorer. The image below shows all of the newly established project's directories as well as the pom.xml file.
2. Building the Maven Project in Eclipse
First, choose the project and proceed to "Run As -> Maven Build”.



3. Building and Running the Maven Project in Eclipse
Select the maven project and choose "Run As > Java Application" to run it.
Select the App class in this scenario, then press the Ok button.

package project.first;
public class App {
public static void main(String[] args) {
System.out.println("Hello World");
}
}

The "Hello World" output will be visible in the Console window.
4. Using Maven to create a Java Web Project in Eclipse
The process for using Maven to create a Java web project is much the same. The primary distinction is that we will make a web application project using "maven-archetype-webapp."
Build the project after selecting the "package" goal, and the console should display the message "BUILD SUCCESSFUL."
Be aware that the maven-example-webapp. The war file is produced during the project build and placed in the target directory.

5. Changing a straightforward Java project to Maven
For managing dependencies and builds, Maven is advised. Sometimes, we work on a simple Java project. It is easy to convert a straightforward Java project to a maven-based one. Let's say we have a straightforward Java project, as shown in the picture below.
It will open a new window to allow you to build a pom.xml file.

The below code depicts the maven project structure and the newly created pom.xml file.
<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>
<groupId>welcome</groupId>
<artifactId>welcome</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>