Maven interview question set 1/Maven Interview Questions and Answers for Freshers & Experienced

What does ‘Maven Clean’ imply?

<> Maven clean is a plugin as the name suggests, that approaches to clean the files and directories generated by Maven at the time of its build.

<> The plugin removes the target folder that contains all the class files, docs, JAR files.

What is a goal in Maven terminology?

The goals mentioned here in the Maven suggest the managing and building process requires creating a project. There is no limitation to follow the goals in Maven; it can build as many phases as it wants with zero boundations. You directly achieve your goal without any kind of outside intervention.

What are the steps involved in project deployment?

There are several steps to follow while implying project deployment in Maven. These steps include:

1. Go through all the projects and analyze the code that is working in the background in progress in the source code repository and identifies it.
2. In order to get the project development, one needs to download the whole source code from the Social Venture Network.
3. Constructor develop the application in the system
It needs to be saving as a War or Jar file system.
4. Get the specified file from the location path and move that specific file to create a site.
5. The application that is created in the system needs to be updated with the latest version with the date and version number.

What are Maven build plugins?

1. Antlr Plugin – Generates parsers that you can use in your code from a very concise domain-specific language.

2. QueryDSL Plugin – Interrogates your database and creates data access objects that you can use to write SQL- like queries in your Java code.

3. Test Report Plugins – Make cool report websites that show you how well your unit tests are covering your code.

4. Shade Plugin – Allow you to bundle all of your classes into an uber-Jar that is runnable. This way you can deploy just one artifact. Also, can change packages of your dependencies to work around conflicts.

What are the archetype goals?

Four goals associated with archetype plugin:

<> Create - creates using a quick-start template.
<> Generate – provide a menu of templates.
<> Create-from-project – creates an archetype from an existing project.
<> Crawl – searches the repository for archetype and updates catalog.

Which command is used to build a Maven site?

- mvn site command is used to build a Maven site
The resulting site, by default, is target/site/…

How does Maven Architecture work?

Maven architecture works in three steps, which are as follows:

1. The first step is to read the pom.xml file.
2. Then, it downloads the dependencies defined in pom.xml into the local repository from the central repository.
3. Lastly, it creates and generates a report according to the requirements, and executes life-cycles, phases, goals, plugins, etc.

What is the meaning of the message “You cannot have two plugin executions with the same or missing elements”?

It simply means that you have executed a plugin multiple times with the same <id>. To correct this you just need to provide each <execution> with a unique <id>.

So now we have come to an end of this blog on Maven Interview Questions. We have tried to cover almost everything in this blog. If you feel that we have missed out on something then please tell us about it in the comment box below.


With a configuration-based build, too, developers have to create the project structure and manually build processes specifying each configuration. In the Maven, style convention is followed where developers do not create build processes. In a convention-style, the developer needs to create a project, and Maven will create the structure based on the type of the project. Developers then will have to follow the convention created by Maven and plant files in the right locations. This eliminates the need to mention any configuration details within a pom file.

Explain the error “You cannot have two plugin executions with the same ( or missing) elements” in Maven.

This error message comes in the situations where we have run a single plugin more than one time with the same id. We need to give a unique id for each execution.

How to perform a force update in Maven?

A forced update in Maven can be done with the following commands:

mvn clean install –U

-U is used for forcing a Maven update. However, the dependencies that are release based cannot be performed in this manner.

What are the elements in POM that a profile can freely modify when specified in the POM?

<repositories>, <pluginRepositories>,<dependencies>, <plugins> ,<properties>, <modules><reporting>,<dependencyManagement>,<distributionManagement>

If you fail to define any information, where does your pom inherits that information from?

All POMs are inherited from a parent despite explicitly defined or not. This base POM is called Super POM and it contains values that are inherited by default.

s it possible to refer a property defined in your pom.xml file?

1. To refer a property that is defined in your pom.xml, the property name uses the names of the XML elements that define the value, with “pom” being allowed as an alias for the project element i.e root.

2. So ${} points to the name of the project, ${pom.version} refers to the project version, ${} refers to the final name of the file created during the built project packaging etc.

How Maven handles and determines what version of dependency will be used when multiple versions of an artifact are found?

If you find two dependency versions at the same depth in the dependency tree, then you use the first declared dependency. This is nothing but dependency mediation.

What is the method and installing process of Maven?

Download Maven from:
Choose the .zip format.

Extract Maven to:

/usr/local/maven – Unix / Linux
C: Program Filesmaven – Windows

What does dependency management mean with respect to transitive dependency?

It simply means to directly specify the versions of artifacts to be used when they are encountered in transitive dependencies. For example project C can include B as a dependency in its dependencyManagement section and directly control which version of B is to be used when it is ever referenced.

When does Maven use the External Dependency concept?

Maven dependency management uses the concept of Maven Repositories (Local, Central, Remote). Suppose dependency is not present in any of remote repositories and central repository then in such case Maven uses the concept of External Dependency.

Is there a particular sequence in which Maven searches for dependency libraries?

Following is the search pattern –

1. Search for dependency in the local repository, if not found, move to step 2 else do the further processing.
2. Search for dependency in the central repository first, if not found and the remote repository is mentioned then move to step 4 else it is downloaded to the local repository for future reference.
3. If a remote repository has not been mentioned, Maven simply stops the processing and throws an error (Unable to find dependency).
4. Search for dependency in the remote repository first, if found it is downloaded to the local repository for future reference otherwise Maven is expected to stop processing and throws an error.

What is the purpose of command mvn clean in Maven?

mvn clean aims to clean the project artifacts created by the previous Maven builds from the target directories. This is generally executed before initiating a new build process.

What is the location where Maven dependencies are downloaded?

The project artifacts, dependencies, and jars downloaded by Maven are placed in the local repository of Maven. The folder .m2 is by default the location for the local repository. This default location can be changed from the settings.xml file.

What does goal in Maven mean?

A collection of Maven goals constitute a phase. Each goal is defined for a particular job involved in project management and execution of the build.

What is known as SNAPSHOT in Maven?

Maven snapshot is that version which is still unreleased. Prior to the first release is completed, there is a 1.0-SNAPSHOT version. In the future, this version will emerge to be 1.0 version. It is called as the present development copy. Maven looks for the new SNAPSHOT version in the remote repository.

How to determine the version of Maven in our system?

To determine the version of Maven we are using in our system, we need to enter the below command in the console.

mvn –version

List down the various scopes of Maven Dependency.

The various scopes of Maven dependency include:

> Compile: This scope is required to build, test, and run the project and is available by default.
> Provided: This scope is needed to build and test the project and is available at runtime.
> Runtime: This scope is not required for compilation but needed for execution.
> Test: This scope is needed for compilation and running of the unit test cases.
> System: This scope cannot be taken from the remote repository and need to be placed in the local project path.
> Import: This scope is utilized when the dependencies are of pom type.

Explain the various types of Maven Repositories.

There are three types of Maven repositories.

They are:

1. Local Repository: This is placed in our local machine generally in the .m2 directory. This is generated once we are able to execute a Maven command successfully. All the project dependencies reside here. Once Maven scans the pom file, it first searches for its dependencies in the local repository.
2. Central Repository: This is supplied by Apache Maven. It contains most of the routinely used libraries. Once any of the dependencies are not found in the local repository, then Maven connects to a central repository.
3. Remote Repository: Sometimes companies develop their own custom repository comprising of their project artifacts, jars, and libraries. This is a type of repository that remains private for use inside that organization.

What do you mean by a Maven Repository?

Maven repository is the location of a directory where all the related project artifacts, jars, libraries, plugins are kept and can be utilized by Maven easily.

What is Maven Archetypes? And what are the Project Types?

Archetypes are templates to create a variety of Java project structures, including web applications specific to a container such as Wildfly. In other words, it is a tool that creates the stuff you build the project on top of.

Project Types:

1. War
2. Jar
3. Ear
4. Wildfly
5. JMS
6. Android

What is a build tool responsible for?

Build tools are primarily responsible for producing the source code (provided the auto-generated code is utilized). It creates project documentation from the source code.

It compiles and packages the code in the form of JAR/ZIP file. Finally, places that code in the local, central, or remote repository.

What is the use of the execution element in the pom file?

The execution element contains information required for the execution of the plugin.

What are the phases of the clean life cycle?

The clean life cycle consists of the following phases

• pre-clean

• clean

• post-clean

What are the different types of Build Profiles?

Build profiles are of 3 types they are as follows,

• Per project - defined in the project POM file, pom.xml

• Global - defined in Maven global settings XML file

• Per User - defined in Maven settings XML file

What are the phases of a Maven Build Life Cycle?

The phases of the Maven Build Life Cycle are as follows,

• validate - This validates the correctness of the project and ensures all the necessary information is available.

• compile - Used to compile the source code of the project

• test - Used to test the compiled source code with a unit testing framework. This does not require the code to be packaged.

• package - This is used to packaged the compiled code and package it into a distributable format such as a JAR.

• integration-test - Used to run integration test on the packaged file

• verify - run checks on the packaged file is valid and meets the required quality criteria

• install - install the package into the local repository to be used as a dependency in other projects locally

• deploy - used in release environments to deploy copies of the final package to the remote repository for sharing with other projects and developers.

You mentioned the Maven repository. What do you mean by that? Are there any types of it?

As the name suggests, the Maven repository may be defined as a container of all the JAR files and Maven files and associated plug-ins. In fact, concerned artifacts are also stored in the Maven repository for suitable applications. There are three types of Maven repository: local repository, central repository and remote repository. Each type stores the relevant project files which are used accordingly by Maven.


With a configuration-based build, too, developers have to create the project structure and manually build processes specifying each configuration. In the Maven, style convention is followed where developers do not create build processes. In a convention-style, the developer needs to create a project, and Maven will create the structure based on the type of the project. Developers then will have to follow the convention created by Maven and plant files in the right locations. This eliminates the need to mention any configuration details within a pom file.

What phases does a Clean Lifecycle consist of?

The clean lifecycle consists of the following phases −




What would the command mvn clean dependency:copy-dependencies package do?

This command will clean the project, copy the dependencies and package the project (executing all phases up to package).

What is a goal in Maven terminology?

A goal represents a specific task that contributes to the building and managing of a project. It is bound to zero or more build phases. A goal that is not bound to any build phase could be executed outside of the build lifecycle by invocating it directly.

What are the different phases of a Maven Build Lifecycle?

Following are the phases of Maven build lifecycle −

validate − validate the project and check if everything is correct and all necessary information is available.

compile − this phase compiles the source code of your project.

test − tests the compiled source code by using a suitable unit testing framework. These tests should not require the code to be packaged or deployed

package − takes the compiled code and packages it in its distributable format.

integration-test − processes and deploys the package if possible into an environment where integration tests can be run.

verify − runs any checks to verify the package is valid and meets the required quality criteria.

install − installation of the package into the local repository. This is done to use it as a dependency in other projects locally.

deploy − done in an integration environment or release environment. Here the final package is copied to the remote repository for sharing with other developers and projects.

What would the command mvn clean do?

This command deletes the target directory with all the build data before starting the build process.

What is the command to build your Maven site?

Type the command − mvn site

Name the 3 build lifecycle of Maven.

The three build lifecycles are −

clean: cleans up artifacts created by prior builds.

default: used to build the application.

site: generates site documentation for the project.

What is the Maven Build lifecycle?

A Build Lifecycle can be defined as a well-defined sequence of phases. It clearly defines the order in which the goals are to be executed. Each build phase contains a sequence of goals. If one life cycle is executed, all build phases in that life cycle are executed. If a build phase is executed, all build phases before it in the pre-defined sequence of build phases are executed.

Mention the steps for installing Maven on windows.

Maven can be downloaded and installed on windows, linux, and MAC OS platforms. To install Maven on windows, you need to perform the following steps:

>> Download Maven and extract it.
>> Add JAVA_HOME and MAVEN_HOME in the list of environment variables.
>> Add the environment path in Maven variable.
>> The last step is the verification of Maven by checking its version.

What is POM?

Project Object Model (POM) refers to the XML files with all the information regarding project and configuration details.

<> It has the description of the project, information regarding the versioning and configuration management of the project.

<> The XML file is in the project home directory. When we tend to execute a task, Maven searches for the POM in the current directory.

What are the different elements that Maven takes care of?

In the process, it takes care of the following:

> Builds
> Dependencies
> Reports
> Distribution
> Releases
> Mailing list

Maven advantages over Ant?

1. Maven uses Convention whereas ant uses Configuration. In Maven, convention means a standard layout suggested by Maven. If you want a skeleton project of a sample Java application, so Maven is going to give you one set of folders and configurations for those Java applications whereas in the case of Ant you need to have lots of configurations.
2. Maven supports project modularization.
3. Maven also supports dependency management and migration.

Why should one use Maven?

It helps to set up projects very quickly and it avoids complicated build files like build.xml. Maven required files like; it serves the purpose for Maven only.

is a collection of dependencies of your Java Project which one can specify to Maven and then Maven will download all of them from the internet and then store it to some repository i.e. local repository, central repository, and remote repository.

It helps to not bundle all the jars in your package i.e. in your War file or Ear file because all of them are going store in the repository and wherever you install this application that repository will be used for any dependencies lookup. So, your Jar file, War file or Ear file, or your bundle deployment will be very light.

How many projects type available in Maven to choose from?

There is more than thousand Java project as there are templates, skeleton provided to you by Maven so that you do not have to remember a basic configuration detail or a basic setup of that particular type of project which Maven is going to give it to you. It includes examples like basic Java project, Spring Project, Spring MVC, Spring Web Flow, and Spring Boot.

What is Maven?

In another word, Maven is a Java tool. If you want to create a sample project or skeleton project you can use Maven. It is an automated build tool. The Maven focused on simplicity that it generates intelligent starters and assumes intelligence defaults. It also covers build-oriented phases in Application Lifecycle Management i.e. testing, deployment, builds management, and release versioning.

R4R Team
R4R provides Maven Freshers questions and answers (Maven Interview Questions and Answers) .The questions on website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers,Maven interview question set 1,Maven Freshers & Experienced Interview Questions and Answers,Maven Objetive choice questions and answers,Maven Multiple choice questions and answers,Maven objective, Maven questions , Maven answers,Maven MCQs questions and answers Java, C ,C++, ASP, C# ,Struts ,Questions & Answer, Struts2, Ajax, Hibernate, Swing ,JSP , Servlet, J2EE ,Core Java ,Stping, VC++, HTML, DHTML, JAVASCRIPT, VB ,CSS, interview ,questions, and answers, for,experienced, and fresher R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for Maven fresher interview questions ,Maven Experienced interview questions,Maven fresher interview questions and answers ,Maven Experienced interview questions and answers,tricky Maven queries for interview pdf,complex Maven for practice with answers,Maven for practice with answers You can search job and get offer latters by studing .learn in easy ways .