Maven Interview Questions

Explain what is Maven? How does it work?

Maven is a project management tool. It provides the developer a complete build lifecycle framework. On executing Maven commands, it will look for POM file in Maven; it will run the command on the resources described in the POM.

List out what are the aspects does Maven Manages?

Maven handles following activities of a developer

-Build

-Documentation

-Reporting

-Dependencies

-SCMs

-Releases

-Distribution

-Mailing list

Mention the three build lifecycle of Maven?

-Clean: Cleans up artifacts that are created by prior builds

-Default (build): Used to create the application

-Site: For the project generates site documentation

Explain what is POM?

In Maven, POM (Project Object Model) is the fundamental unit of work. It is an XML file which holds the information about the project and configuration details used to build a project by Maven.

Explain what is Maven artifact?

Usually an artifact is a JAR file which gets arrayed to a Maven repository. One or more artifacts a maven build produces such as compiled JAR and a sources JAR.

Each artifact includes a group ID, an artifact ID and a version string.

Explain what is Maven Repository? What are their types?

A Maven repository is a location where all the project jars, library jars, plugins or any other particular project related artifacts are stored and can be easily used by Maven.

Their types are local, central and remote.

Why Maven Plugins are used?

Maven plugins are used to

-Create a jar file

-Create war file

-Compile code files

-Unit testing of code

-Documenting projects

-Reporting

Inclined to build a profession as Maven Developer? Then here is the blog post on
 Online Maven Training.

List out what are the build phases in Maven?

Build phases in Maven are

-Validate

-Compile

-Test

-Package

-Install

-Deploy

List out the build, source and test source directory for POM in Maven?

-Build = Target

-Source = src/main/java

-Test = src/main/test

List out what are the Maven’s order of inheritance?

The maven’s order of inheritance is

-Parent Pom

-Project Pom

-Settings

-CLI parameters

Explain how you can produce execution debug output or error messages?

To produce execution debug output you could call Maven with X parameter or e parameter.

Explain how to run test classes in Maven?

To run test classes in Maven, you need surefire plugin, check and configure your settings in setting.xml and pom.xml for a property named “test.”

What are the advantages of Maven?

-No need to add jar file in each project

-Creates right directory structure

-Builds and deploys the project

What it does?

Maven simplifies the above mentioned problems. It does mainly following tasks.

It makes a project easy to build

It provides uniform build process (maven project can be shared by all the maven projects)

It provides project information (log document, cross referenced sources, mailing list, dependency list, unit test reports etc.)

It is easy to migrate for new features of Maven

Apache Maven helps to manage

-Builds

-Documentation

-Reporing

-SCMs

-Releases

-Distribution

Interested in mastering Maven? Learn more about Maven Tutorials in this blog post.

What features should  a build tool have?

A build tool should have:

-Compile java code and build jar, war and ear files for deployment and release.

-Versioning and dependency management

-Run tests and report test results

-Run code quality check with Sonar, Checkstyle, Findbugs, etc.

-Environment property substitution

-Files generations ( wsdl, AspectJ, XSL,etc)

-Support for cross platform (UNIX Windows) and IDEs(eclipse, Netbeasn, Intellij)

-Proper documentation and support.

What is a transitive dependency in Maven?

Transitive dependency in Maven means that it is not necessary to discover and specify the libraries that our own dependencies require, Maven includes them automatically.

What is the difference between version and SNAPSHOT ?

Maven will download  always the specified version. In case of SNAPSHOT Maven will download the latest SNAPSHOT.

What is a Mojo?

A mojo is a Maven plain Old Java Object . Mojo is associated with a Maven goal. A custom plugin is a set of related Mojos (or goals) in a single plugin artifact.

What does the Maven command mvn clean do?

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

What are the phases of the Maven Build Lifecycle?

The phases of the Maven Build Lifecycle are:

-Validate

-Compile

-Test

-Package

-Integration-tests

-Verify

-Install

-Deploy

Summary
Review Date
Reviewed Item
Maven Interview Questions
Author Rating
51star1star1star1star1star

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Maven Interview Questions"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Support


    Please leave a message and we'll get back to you soon.

    3 + 5