Apache Maven Interview Questions & Answer [GUIDE TO CRACK]
Maven Interview Questions and Answers

Apache Maven Interview Questions & Answer [GUIDE TO CRACK]

Last updated on 04th Jul 2020, Blog, Interview Questions

About author

Kernel (Team Lead - WPF )

High level Domain Expert in TOP MNCs with 8+ Years of Experience. Also, Handled Around 20+ Projects and Shared his Knowledge by Writing these Blogs for us.

(5.0) | 16547 Ratings 744
These MAVEN Interview Questions have been designed specially to get you acquainted with the nature of questions you may encounter during your interview for the subject of MAVEN . As per my experience good interviewers hardly plan to ask any particular question during your interview, normally questions start with some basic concept of the subject and later they continue based on further discussion and what you answer.we are going to cover top 100 MAVEN  Interview questions along with their detailed answers. We will be covering MAVEN  scenario based interview questions, MAVEN  interview questions for freshers as well as MAVEN  interview questions and answers for experienced. 

1) What is Maven?


Maven is a project management and understanding tool. Maven provides developers with a complete life-style design. With the use of a standard directory structure and the default lifespan cycle, the development team can build the structure of the project at any time.

2) How does Maven manage?


Maven provides ways for developers to manage the following:

  • Builds
  • Documentation
  • Reporting
  • Dependents
  • SCMs
  • Publications
  • Distribution
  • Mail list

3) How do you know the version of MVN you use?


 Enter the following command –

mvn – version

4) What is balm?


 The project object refers to the POM model. This is the base unit that works in Maven. This is an XML file. It always lives as a pom.xml in the base directory of the program. The project (s) contains information about the project used and the structure of various structures used by Maven.

5) What is the Maven occupation?


An artistic file is a file, usually sent to a JAR repository by JAR. Creates a masterpiece of one or more artifacts, such as compiled JAR and “sources” JAR.Each artificial group is a group ID (usually the reverse domain name, com.example.foo), a satellite ID (a name) and a version string. Three find a unique identity together. Functions of a project are represented as complications.

6) What is a storehouse?


A directory that contains the compiled JAR file pom.xml file as a soft repository. Maan is looking for dependents in the barns. … local repository. Central repository. Remote repository.

7) What is the Maven area repository?


 Local repository. Maven’s local repository is a folder of the developer engine, where all the projects are stored locally. When Maven is implemented, Maven automatically downloads all the independent jars in the local store. This folder is usually named. M2.

8) What is the structure profile?


 A configuration profile is a set of configuration values that can be used to set or ignore the default values of the Maven Building. Using the creation details, you can customize it to various environments, such as production v / s development environments.

9) What are the different architectural profiles?


 There are three types of create profiles –

A project – project POM file, defined by pom.xml.

A user – defined mammon in the xml file (% USER_HOME% / .m2 / settings.xml).

Global – Manual Universal systems are defined in the xml file (% M2_HOME% / conf / settings.xml)

10) What is a Maven Store?


 There is a repository that can be stored in jazz, library jar, plug-in or any other specific artwork in all the projects, and Maven can easily be used.

11) What is the local repository?


Maven is a folder on your computer as a local repository. This will be created when the first time you execute any superior command. Maven’s local repository keeps all of your project’s functions (library jars, plugin jars etc.).

12) What is the default location for your local repository?


 ~ / M2 / repository.

13) What is the command to install the JAR file in the local repository?


mvn install

14) What is Central Storage?


This is a repository provided by the Maven community. These are commonly used libraries. If Maven does not see any kind of local repository in the local repository, the following URL begins to search in the central repository: http://repo1.maven.org/maven2/.

15) What is the Arctic?


The arctic is a dynamic plugin and its mission is to create a project structure according to its template.

16) What is the command to create a new project based on a hard drive?


Enter the following command -mvn archetype: create

17) What does dependency management mean in the dependable function environment?


 They represent versions of the straightforward components, which must be used when interacting with intermediate functions. For example, project B may be dependent on behalf of B. Direct control of the admin control unit and any version of B controlled directly.

18) What is the default value for the packaging element?


 Valid packaging values are some jar, war, ear and go. If the packaging value is not specified, it will automatically run to the jar.

19) What is the full name of a project?


<GroupId>: <artifactId>: <version>

20) What is a prohibition?


Any sort of relativity can be removed using the “delete” element. For example, A and C are excluded C because B and P are dependent on C.

    Subscribe For Free Demo

    21) What is the central repository of Maven?


    Maven is a repository of words, which can easily be used in all projects, library jar, plug-ins or any other definite art galleries. The Maven Storage is of three types.

    22) What is the use of Settings XML in Maven?


    A maven settings.xml file defines the values that configure the Maven function in different ways. Usually, it is used to define a local storage space, alternate remote storage servers, and authentication information for individual repositories.

    23) What’s Maven Central Gradually?


     A module dependency generates the output of a particular function on a module behalf. Volumes are usually stored in a repository, such as Maven Central, a corporate maven or repository or a directory in a local file system.

    24) Is Maven available to Java?


    Ungrounded objects can be challenged and removed. Maven is primarily an automation tool used for Java projects. Maven will store Java libraries and Maven plugins in one or more repositories as a central repository and store them in a local cache.

    25) How to override the default name of the war file ?


    You can use the element <finalName></finalName> in your pom.xml file to override the default name of the war file.

    26) What is the element used to specify the dependencies in your pom.xml ?




    27) If we build the parent project in a multi module setup Maven will build all the child projects/modules ?



    28) Using which element in the child modules pom.xml do we refer to the parent pom ?




    29) Using which element does maven allow us specify the visibility of dependencies ?




    30) What are six types of scopes ?


    • Compile
    • Runtime
    • Provided
    • Test
    • System
    • Import
    Course Curriculum

    Take Your Career to Next Level with Maven Training to Build Your Skills

    • Instructor-led Sessions
    • Real-life Case Studies
    • Assignments
    Explore Curriculum

    31) What compile type scope ?


     If we use compile type scope, then those dependencies will be available during the project build, that is when the classes are compiled, tests are compiled, when the tests, applications run.

    32) What is the default scope that the maven uses if we do not specify scope element in pom.xml ?



    33) What happens when we declare dependencies under the scope provided ?


    It means that those are the dependencies which are required during build test and run but they are not required to be exported, meaning they need not be part of the application when it is deployed.

    34) What scope can be used to make certain dependencies to be available only during compiling and running tests ?



    35) Example of dependency which can be declared under test scope ?



    36) What are maven profiles?


    Maven profiles are used to set up environment specific configuration files. We need to use the profile tag in the pom.xml file to set up environment conf files.

    37) Difference between Ant and Maven.


    • Ant and Maven are both build tools from the Apache company.
    •  Maven is a framework and ant is tool
    • Maven having lifecycles, ant wont having.
    • Maven scripts are stored pom.xml file and ant scripts are stored in build.xml
    • Maven plugins are reusable and ant tags are reusable.

    38) Explain about the Maven repositories.


     There are three types of maven repositories.

    • Local repository
    • Central repository
    • Remote repository

    While downloading the jars, First it will look into local , central and remote . it will download the jars and compile code in the above order.

    39) Explain about the maven plugins.


    • Maven is the plugin based framework. Each activity in maven depends on a plugin. All the maven plugins are stored in the group “org.apache.maven.plugins”.
    • Ex: To compile java code, we  need to use maven-jar-plugin
    • To create a jar file, we need to use “maven-jar-plugin” and so on.

    40)What are maven dependencies?


    • Maven dependencies are used to compile the code.
    • All the dependencies are called in the between the tags in pom file <dependencies></dependencies>

    41) Explain about the maven lifecycles.


    • clean is used to delete the existing target directory.
    • Validate is used to check the syntax of the maven pom file.
    • Compile is used to compile the source code
    • Install is used to create a jar /war/ear file.

    42) Explain about the system and provided.?


    •  <scope>system</scope> is used to represent the local jars inside the pom file.
    • <scope>provided</scope> is used to avoid the jar from the WEB-INF/lib folder of the war.

     43) What is archetype?


    • We will use maven archetype to generate the maven folder structure based on the inputs.
    • Ex: mvn archetype:generate.

    44) What is the maven pom?


    •  Maven pom stands for project object model.Every pom file must contain, projectId , artifactId, version and packaging tags. And also we need to call all the dependencies in between the dependencies tag.
    • <dependencies></dependencies>
    • Along with that we need to call the <build></build> tag to build the code.

    45) What is the version to use to check maven version


    mvn –version

    46) Explain about the parent pom file.


     We can use the maven parent pom file to call the other modules.

    47) What maven modules?


    •  we can use maven modules in the parent pom file as a module.



    • Each module has a separate pom file.

    48) Which is the command I will use to add the jar manually in the pom file under dependency.



    49) Explain about the maven settings.xml file?


    It contains the below configuration

    • Prody configuration
    • Local repository configuration
    • Remote repository configuration
    • Central Repository configuration

    50) In which way the dependencies jar files are downloaded from net.


    • First it will the jar in local, if available it will take from local and compile the code.
    • If the jar is not available in local repo, then it will got central repo and download the jar and will compile
    • If the jar is not available in central , it will go remote repo and download the jar and compile the code .
    • If the jar is not available in three places, maven will fail the build.
    Course Curriculum

    Get Maven Certification Course with Industry Standard Modules

    Weekday / Weekend BatchesSee Batch Details

    51)What is the advantage of Maven?


    • Easy to download the Jar file using Dependency
    • Configuration setup is easier
    •  Project View

    52) what are the types of POM configuration?


    Mail List, Plugins, goals, projects version and build profile.

    53) what are GroupId references?


    GroupId is nothing but reverse domain access and it will refers which file location

    54) what are ArtifactsId references?


    ArtifactsId is nothing but a filename to download in the accessed domain and it will refer to the file name.

     55) what are Version and Scope references?


    Version which defines the version control and scope which refers to the file name.

     56)What does the mvn clean command?


    mvn clean command is used to remove the target location file of before and after build starts.

     57) What is the Maven Repository referred?


    where the place we can see all the project jars,plugins and library jar file and Store easily in maven

     58)what are the types of Maven Plugins?


    • Report Maven Plugin
    • Build Maven Plugin

     59)Define MOJO?


    A MOJO defines as a Maven plain Old Java Object. it is an executable goal of maven plan.

     60) Maven differentiation with Selenium webdriver?


    •  In selenium web drivers, invalid jar files are added to the project as library files, whereas in maven the jar files are added as dependencies.
    • In Selenium Web driver, for every individual project, it is essential to add all the jar files again to the new project, whereas this can be overcome by using maven by adding a pom.xml file to the new project.

     61)How to exclude dependencies?


    By using the exclusion element. Exclusions are specific dependencies in your POM, and are targeted at a specific groupId and artifactId.

     62) which command removes the target directory before the start of a build process?


    mvn clean command

     63) Processes involved in achieving the project?


    Maven helps in creating a Java-based project more easily. Accessibility of new features created or added in Maven added to a project in Maven configuration.

     64)which Languages are supported by maven?


    • C#,
    • Ruby,
    • Scala,
    • other languages

     65)pom.xml file?


    Collections of dependencies instead of jar files with group ID and artifact ID

     66) How pom helps maven?


      POM is a page object model. It represents the basic unit of work in maven. POM contains the configuration as

    build profiles.

    • project version.
    • developers.
    • mailing list.

    project dependencies.

    • plugins.
    • goals

     67) what is clean, default and site in maven?


    • Clean represents cleans up artifacts achieved by previous builds.
    • Default (or build): this can be customized to build the appliance.
    • Site: generates site level documents for the project.

     68) how do test and package phases imply in maven?


    • Test −  the compiled source code involves the appropriate unit testing framework and these tests do not require the code deployed or packaged.
    • Package − take the compiled code and package in a particular format like a JAR.

     69) Features of build tool?


    • Compile Java code and build jar for deployment and release.
    • Versioning and dependencies management
    • Run to look at and report test results
    • Run code analysis check with Sonar, check style, Find bugs, etc.

     70) runtime in maven ?


     It represents that the dependency will not be required for compilation

    Maven Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download

    71) What do you mean by build profile in Maven?


    Build profile in Maven refers to a set of configuration values through which a user can set a default value or can override the default values of Maven build. Users can customize build for several environments using a build profile. Profiles could be able to modify the POM at build time. They are also used to provide parameters for various target environments.

    72) What are the types of Build profiles in Maven?


     The build profile of Maven is of three types. They are:

    • Per-project: It is specified in the project file i.e POM file, pom.xml
    • Per-user: Specified in the Maven settings XML file(settings.xml-can be accessed from root folder)
    • Global: Specified in the Maven global settings XML file

    73) What are the ways to activate a Maven build profile?


    The build profile of Maven can be activated using several ways. They are:

    • Through settings of Maven
    • Explicitly using the command prompt (command console)
    • Based on user or system variables (environment variables)
    • Operating System settings
    • Through current files or missing files.

     74)What is the Mayan occupation?


     An artistic file is a file, usually sent to a JAR repository by JAR. Creates a masterpiece of one or more artifacts, such as compiled JAR and &quot;sources&quot; JAR.Each artificial group is a group ID (usually the reverse domain name,com.example.foo), a satellite ID (a name) and a version string. Three find a unique identity together. Functions of a project are represented as complications.

    75) What will happen once a Maven command is passed to run a phase?


    Once a phase is invoked through Maven command, (say for example mvn test), till that phase and inclusive of the called phase only will get executed.

     76) What do you know about Maven?


    Maven is actually a tool for Project management and Comprehension from Apache, which supports the users to create a framework for lifecycle. Using the inner piece of information, Maven could be able to manage new project creation, reports and documentation. Maven can be used to manage and create any project based on Java. The project build infrastructure in Maven can be automated by a team of developers quite simply and quickly because Maven uses a common build lifecycle and a standard directory. Maven is capable of setting up the working method standards too quickly while developers working in a different development team environment. Maven is very much user friendly as most of the project setups are quite easy and reusable.

     77) What are the primary objectives of Maven?


    The primary objective of maven is to support the developer with key features following:

    • To provide the developer an extensive model to set up projects to make it reusable, easily maintainable and easily understandable.
    • To support with tools or plug-ins which interact with the demonstrative model.

     78) What is the command to know which version of Maven you are using?


     The command to know the version of Maven is:

    $mvn –version

     79) What is the support Maven offers to the developers?


    Maven supports the developers to control and administer:

    • Project creations (builds)
    • Reports
    • Documentation
    • SCMs
    • Dependencies
    • Mailing lists
    • Releases and
    • Distribution

     80) What do you mean by POM in maven?


    POM in Maven refers to the Project Object Model, which is the principal object model for a work or a project. POM has an XML file which contains the information about the project and other configuration information to create a project in Maven.

     81) What are the configurations that can be specified in POM?


    The following are some of the configurations that can be specified in POM:

    • Plug-ins
    • Build Profiles
    • Project Dependencies
    • Mailing Lists
    • Project Version
    • Goals

    There are some prerequisites before creating POM. The developer has to decide the project group i.e group ID, name of the project (artifact ID) and the version. These attributes help the developers to identify the project in your repository.

     82) What is the use of Maven?


    Maven was actually built to make the build processes present in Jakarta Turbine projects easier and simpler. Further, Maven was enhanced by Apache to create various projects together, publish the information of projects and to share the JAR files present in various projects so as to support the association of teams.

     83) What is the difference between Convention and Configuration and state why Maven uses Convention?


    In case of Configuration, developers need to create the build processes manually and have to specify each and every configuration in detail. But, Maven uses convention instead of configuration, where the developers need not create the build processes, whereas Maven does it automatically. Also, for convention, users need not specify the configuration in detail. Once a developer creates a project in Maven, it will automatically create a structure. Developers have to place the files appropriately. There is no need to specify any configuration details in pom.xml.

     84) State the features present in Maven?


    The following are some of the features present in Maven:

    • Maven follows a very simple project setup thereby simplifying developer’s tasks.
    • Steady utilization of resources among all the projects.
    • Frequently updated vast collection of libraries
    • Automatically updates it.
    • Dependency management
    • User can extend with plug-ins in Java or some other programming languages
    • It permits support and access immediately to the latest features with little or no configuration.

     85) How will you install Maven on to your machine?


    Installing Maven requires installation of Java because Maven is a tool based on Java. Maven can be installed in Windows, Linux and Mac as per the user’s wish. The following are the basic requirements to install Maven in your machine:

    • Install JDK 1.7 or higher on to your machine. Verify Java installation on your machine.
    • Set Environment variables for Java
    • Download Maven Archive from Apache website. There are separate archives available for windows, Linux and Mac OS. Download the archive as per your need.
    • Extract the Maven archive.
    • Set Environment variables for Maven.
    • Add the Maven bin directory location to the system path.
    • Verify the Maven installation using the command: $ mvn –version

     86) Explain the use of Maven artifacts?


    Maven artifact is a Jar file present in the Maven repository. With one or multiple artifacts in a Maven build produces a compiled Jar or sources of Jar. Every artifact will contain a group ID, version number and an artifact ID.

     87) State the differences between Apache Ant and Maven?


    Apache Ant Maven
    Apache ant is basically a tool boxMaven is a framework

    Apache Ant will not support any formal conventions such as project directory

    Maven supports formal


    Apache Ant does everything procedurallyMaven does things in a

    declarative way

    It is not possible to reuse the scripts of AntThe plug-ins of Maven

    were reusable

    Ant will not contain a lifecycle. User has to manually add the sequence of tasks about to be


    Maven contain a life


    88) How many POMs can be created for a project? Explain the minimum requirements for POM?


    Only one POM file can be created for a project. For every POM file, project element, group id, artifact id and version are mandatory. Every project has to be stored in the repository like the following notation: groupid:artifactid:version. There are some basic requirements for a POM. They are:

    • Root of the project: Root tag helps you to check the primary specifications such as apache schema and w3.org.
    • Version of the model: The model version should be 4.0.0 or higher.
    • Group Id: Group id is the id for a project group. Usually these IDs were named unique. For example, the group id for an insurance company can be com.company.insurance which contains all projects related to insurance.
    • Artifact Id: Artifact Id is the id for a particular project, usually the name of the project. Artifact Id and Group Id specifies the location of artifact in the repository.
    • Version of the project: To avoid confusions among different versions, version of the project has to be specified. Say for example,


    com.company.insurance:consumer:insurance:1.2  and so on.

     89) What do you mean by Super POM?


    The default POM of Maven is the Super POM. All POMs can be derived from a parent or by default. This POM is the basic POM and is also known as super POM. Super POM will contain default derived values. To execute the desired objective, Maven uses the effective POM. Super POM supports the developers to configure pom.xml with a minimum configuration. These configurations can be easily modified. The following command is used to check the default configurations of super POM:

    $mvn help:effective-pom

     90) How will you create an effective POM on your computer?


    •  Initially, create a pom.xml in some directory of your computer. Specify minimum configuration on your computer. Check the default configuration of the effective POM through the following command:
    • $mvn help:effective-pom
    • Say for an example, create pom.xml in C:MVN/Project Folder
    • Then, open the command prompt (windows), navigate to the folder of pom.xml, execute mvn command.
    • C:MAVEN/Project >mvn help:effective-pom
    • Now, Maven will begin to process and the effective POM can be visualized in the console after the successful application of interpolation, inheritance and profiles.

     91) What do you mean by build life cycle? Explain the phases of the build life cycle?


    A build life cycle can be defined as a decisive order of phases. Phases define the sequence in which the desired goals to be accomplished. Phase refers to a stage in the life cycle. A distinctive Maven build life cycle will comprise the following order of phases.

    • Prepare-Resources: In this phase, users can customize resource copying.
    • Compile: This phase compiles the source code
    • Validate: This phase validates the project if the project and other information provided were correct.
    • Test: This phase tests the compiled source code which is suited for testing the framework.
    • Package: Creates the package JAR/WAR .
    • Install: Installs the package into the remote or local repository of Maven.
    • Deploy: This phase copies the final package into the remote repository.

     92) What do you mean by Goal in the Maven life cycle?


     Pre-phase and Post-phase goals will be present and these goals run before or after a specific phase. Once Maven begins to build a project, it follows the already defined order of phases and execution. Goal refers to a particular task which assists to build and manage a project. There could be no goals or it could build more phases. The sequence of execution depends on the order of goals and the build phases are called.

     93) List the standard life cycles of Maven?


    There are three standard life cycles available for Maven. They are:

    • Clean
    • Build (default)
    • Site

     94) Explain Clean life cycle in Maven?


    While executing the mvn post-clean command, Maven calls the clean life cycle. It consists of the following phases:

    • Clean
    • Pre-clean
    • Post-clean

    The goal of clean phase in Maven lies within the clean life cycle. Clean:clean goal thus removes the build output by deleting the build directory. Once  mvn clean command is executed, maven deletes the build directory. Developers can also customize the role of goals by specifying goals in any phase of the clean life cycle.

     95) Explain Default life cycle in Maven?


     As the name implies, default is the basic life cycle of Maven to build the application. Default lifecycle contains 21 phases namely validate, initialize, generate-sources, generate-resources, process-sources, process-resources, compile, process-classes, process-test sources, generate test-sources, process-test-classes, test, test-compile, package, prepare-package,  pre-integration-test, post-integration-test, integration- test, verify, install and deploy.

     96) Explain Site life cycle in Maven?


     Site lifecycle in Maven is a plugin which is normally used to make new documentation to create reports, to deploy a site and many more. The site life cycle consists of the following phases:

    • Site
    • Pre-site
    • Post-site
    • Site-Deploy

    Are you looking training with Right Jobs?

    Contact Us
    Get Training Quote for Free