top of page
image 82.png

What are maven and dependencies in pom.xml?

In this section we will learn about:

​

  • Maven

  • POM

  • Dependency and used dependencies

1. Maven:  Maven is a project management and comprehension tool that provides developers with a complete build lifecycle framework. It makes work easier for developers as we don’t need to download all the dependencies needed for the project. We just need to add them to our POM. Maven also helps us in building JAR files for our project with the help of several maven lifecycles like clean, compile, install, etc.

The default maven lifecycle consists of 8 major steps for compiling, testing, building, and installing a given JAVA project -

​

  • Clean - It cleans the project and removes all the files generated by the previous build.

  • Validate - This step validates if the project structure is correct, that is, it checks if all the dependencies are available in the local repository.

  • Compile - It compiles the source code of the project.

  • Test - It runs the unit tests for the project.

  • Package - This step packages the compiled code in distributable format. It basically creates the JAR or WAR file for the project.

  • Verify - This step runs checks to verify that the project is valid and meets the quality standards.

  • Install - This step installs the packaged code to the local maven repository, that is, it deploys the packaged JAR/WAR file to the local repository.

  • Deploy - This step copies the JAR/WAR file to the remote repository after compiling, running tests, and building the project.

2. POM (Project Object Model): The pom.xml file contains information on the project and configuration information for the maven to build the project such as dependencies, build directory, source directory, test source directory, plugin, goals, etc.

3. Dependency:  A dependency is just an archive—JAR, ZIP, and so on—which our current project needs to compile, build, test, and/or run. Dependencies make things easier as we don’t need to install JAR files for your project.

4. Spring Web:  This dependency has an embedded server like Tomcat and uses Spring MVC, REST, and everything needed to create a web application.

5. Spring Data JPA:  This dependency is used for communication between Service Layer and Data Access Layer. It brings in the concept of JPA(Java Persistence API) Repositories, a set of Interfaces that defines query methods and manipulates the database with predefined methods.

6. Lombok: Lombok is a library that helps in reducing boilerplate java codes (code that is repeated in many parts of an application with little alteration). You can use simple annotations to create getters and setters, constructors, etc.

bottom of page