Maven Demo

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Maven demo

K.Sridhar Patnaik
BIT mesra
• 1)open eclipse IDE
• 2)click →File→New→project-
→maven→maven project as shown
below→next
Select two check boxes as shown,then
click next
Enter group Id and artifact id as shown
click next
A maven project with all folders
created including pom.xml
Double Click pom.xml and at the
bottom find pom.xml and click
Right click on src/main/java than
create a class as shown below
Add some method
Create test case for the sample
helloworld
• Open pom.xml file and add Junit
dependency(google…download maven junit
dependency) you will get …
• <dependency>
• <groupId>junit</groupId>
• <artifactId>junit</artifactId>
• <version>4.12</version>
• <scope>test</scope>
• </dependency>
• Copy the dependency in pom.xml in between
the tags <dependencies></dependencies>
You will see maven dependency added
in the left
• Now Right click src/test/java→new---
other→select Junit test case(or type Junit you
will find Junit test case)→next
Create HelloworldTest then →Finish
Test case created
• Right click maven project and -→run as-
→maven test
• Result -build failure (we have not done any
testing )all the steps are just for showing how
to run a maven project.
• To handle version error (5 or7)
• <dependency>
• <groupId>org.apache.maven.plugins</groupId>
• <artifactId>maven-compiler-plugin</artifactId>
• <version>3.10.1</version>
• </dependency>

You might also like