Maven Interview Questions

Maven Interview Questions | Freshers & Experienced

  • Sharad Jaiswal
  • 06th Sep, 2021
  • 610 Followers

About Maven

Maven is a type of automated tool designed for understanding how software is built using a programming language and how it is dependent on the various codes and functionalities of the basic language. Its basic concepts and components tell you about all the key steps which are involved in the process of web-based application development using these tools and how to manage them.

Key Features of Maven

Below are few major features of Maven

Easy project setup

Automatic Parent Versioning

Parallel Builds

Better Error and Integrity Reporting

Model-based builds

Backward Compatibility

Easily Extensible

Dependency management

Easy updation

Practice Best Maven Interview Questions & Answers

Q1. List few difference between Apache Ant and Maven?

Apache Ant:

  • Ant doesn't have formal conventions.
  • Ant is procedural.
  • There is no life cycle in Ant.
  • Ant is a toolbox.
  • The ant scripts are not reusable.

Maven:

  • Maven has a convention to place source code, compiled code, etc.
  • Maven is declarative.
  • There is a life cycle in Maven.
  • Maven is a framework.
  • The maven plugins are reusable.

Q2. List few advantages of Maven?

The advantages of Maven are:

  • Helps manage all the processes, such as building, documentation, releasing, and distribution in project management.
  • Simplifies the process of project building.
  • Increases the performance of the project and the building process.

Q3. What mvn clean do?

Maven clean is used to clean phase in the clean lifecycle by deleting the output of a build by deleting the build directory.

Q4. What information does POM file contains?

A POM file or Project Object Model file is an XML file that contains information about the project and configuration details used by Maven to build the project.

Q5. What is a Maven Repository?

Maven Repository is basically a directory consists of all the project jars, library jar, plugins or any other project-specific artifacts that can be used by Maven easily.

Q6. How many types of Repository are available in Maven?

There are two types of Repositories available in Maven. These two repositories are:

  • local repository
  • remote repository

Q7. What M2_HOME variable stores?

M2_HOME is a variable used in maven to locate maven 2. It basically tells the program where to find Maven installation.

Q8. What are the elements of a project's coordinates in Maven?

The elements of a project's coordinates in Maven are:

  • groupId- the name of the project
  • artifactId- indicates the module name of the project
  • version- The version name of the project
  • packaging- the way the Maven project is packaged
  • classifier- This element is used to help define some attachments of the build output

Q9. What are the different Maven build lifecycles?

There are three built-in Maven build lifecycles:

  • default - the default lifecycle handles the project deployment
  • clean - the clean lifecycle handles project cleaning
  • site - the site lifecycle handles the creation of the project's site documentation.

Q10. List the phases of the default lifecycle in Maven?

The phases of the default lifecycle in Maven are:

  • validate
  • generate-sources
  • process-sources
  • generate-resources
  • process-resources
  • compile
  • process-classes
  • generate-test-sources
  • process-test-sources
  • generate-test-resources
  • process-test-resources
  • test-compile
  • test
  • prepare-package (maven 2.1+)
  • package
  • pre-integration-test
  • integration-test
  • post-integration-test
  • verify
  • install
  • deploy

Q11. What is an archetype?

An Archetype is a Maven project templating toolkit which is consists of a very simple artifact, that contains the project prototype and creates project structure as per its template.

Q12. How to add a dependency in Maven Project?

We can add a dependency in Maven Project with the help of the following steps:

Step 1 - Right-click the utility project, and select Maven>Add Dependency.

Step 2 - Type a dependency name in the Enter groupID… field to search for a dependency.

Step 3 - Select the dependency, and click OK.

Step 4 - Expand the utility project, right-click the pom.xml file, and select Run As>Maven Install to install the file into the local repository.

Step 5 - View the Console. When it displays “Build Success,” the utility project is available for reference by other projects.

Q13. What is Maven and what can it be used for?

Maven is a powerful project management tool that is based on POM or project object model which is used for building and managing any Java-based project, dependency, and documentation.

Q14. What is dependency exclusion in Maven?

Exclusions are set on a specific dependency in your POM or project object model and are targeted at a specific groupId and artifactId.

Q15. What is the difference items in Repository-Manager and SCM?

SCM stands for Supply chain management which is the centralized management of the flow of goods and services and includes all processes that transform raw materials into final products.

Q16. What does the SNAPSHOT designator in a version indicate?

The SNAPSHOT designator in a version indicates that a project is in a state of development.

Q17. What are transitive dependencies?

A transitive dependency is indirectly formed by two functional dependencies. For e.g. X -> Z is a transitive dependency if the following three functional dependencies hold true:

  • X->Y
  • Y does not ->X
  • Y->Z

Q18. What is the default Logging level in maven?

simpleLogger. defaultLogLevel represents the default log level in Maven.

Q19. How to run multiple profiles in maven in CLI?

To run multiple profiles in maven in CLI we can activate command line: mvn groupId:artifactId:goal.

About Author :

  • Author of Maven Interview Questions

    Sharad Jaiswal

    My name is Sharad Jaiswal, and I am the founder of Conax web Solutions. My tech stacks are PHP, NodeJS, Angular, React. I love to write technical articles and programming blogs.

Leave A Comment :

Valid name is required.

Valid name is required.

Valid email id is required.