0% found this document useful (0 votes)
0 views

Program-2

This document provides a step-by-step guide for creating a Maven project using Eclipse, including installation of Eclipse and Maven, project configuration, and understanding the POM file. It details how to add dependencies and plugins to the project and explains the process for building the project using Maven commands. The instructions aim to help users effectively manage their Java projects with Maven in an Eclipse environment.

Uploaded by

dhyanadarpana29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Program-2

This document provides a step-by-step guide for creating a Maven project using Eclipse, including installation of Eclipse and Maven, project configuration, and understanding the POM file. It details how to add dependencies and plugins to the project and explains the process for building the project using Maven commands. The instructions aim to help users effectively manage their Java projects with Maven in an Eclipse environment.

Uploaded by

dhyanadarpana29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Program 2: Working with Maven: Creating a Maven Project, Understanding the

POM File, Dependency Management and Plugins.

Install Eclipse and Maven


• Ensure Eclipse IDE is installed. You can download it from the official website if
not already installed.

• Ensure Maven is installed on your machine. You can verify its installation by
running mvn -v in the command line.

Open Eclipse and Configure Maven

• Open Eclipse and go to Window > Preferences.

• Navigate to Maven and ensure it's configured correctly, pointing to your Maven
installation.

Create a New Maven Project

• In Eclipse, go to File > New > Other... and select Maven Project.
• Leave the default workspace location and click Next.
• Choose Create a simple project (skip archetype selection) and click Next.

Specify Project Details


• Enter the Group ID (usually your organization or package name).
• Enter the Artifact ID (the name of your project).
• Fill in the Version and Packaging (e.g., jar).
• Click Finish to create the project.

Understand the POM File


• The newly created project will have a pom.xml file in its root directory. This file
is crucial for Maven configuration.
• This XML file includes project configuration details, dependencies, and plugins.

Adding Dependencies
• Open pom.xml.
• To add a dependency, find the dependency information on Maven Repository
(e.g., https://mvnrepository.com/).
Add the dependency snippet within the <dependencies> tag. For example:

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.2.3.RELEASE</version>
</dependency>

Adding Plugins

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>

Build the Project


• Right-click on the project in Eclipse's Project Explorer.
• Select Run As > Maven build....
• In the Goals field, type clean install to clean and install your project.
• Click Run to build the project with Maven, which will download necessary
dependencies and compile the project.

You might also like