What is Maven ?
Our Project needs jars , without jar we can’t use technologies and Framework in our Projects, called as Dependencies.(Jar is collection of .class File)
Maven is used to automate process of Dependencies(i.e jars) which is also Known as Dependency Management Tools.
Where Maven is used?
Multiple jar
Dependencies and version
Project structure
Building, Publishing and Deploying
Maven project if needs any kind of jar file firstly it search in the local repository in .m2 if that jar is not present in .m2 then it send request to Maven Server in the form of pom.xml file.(Project Object Model )
What a pom.xml file has?
· Parent Maven Project Details as Co-ordinates
· Our Project Details
· Properties(k-v)
· Dependencies(.jar)
· Dependency Management
· Plugins
· Metadata
· Build Information
Maven Folder structure:-
Dependency Chain:- One jar may be depending on another jar , then maven provide all set of jars when we request for one jar known as Dependency Hierarchy.
Exclusions:- Removing jar from Maven Dependencies in a chain of jar
Example:-
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
Scope Is used to define the area when jar file should be loaded
Note :- Scope is Optional , if we don’t provide any value to to scope tag then by default it takes Compile value.
Type of Scope:-
Compile:- a jar used at compile & Runtime.
provided:- a jar is given by server/container
runtime:- a jar is used only at runtime
system:- a jar is loaded for System Drives(D:/, C:/)
test:- a jar is used only for unit testing